s.wanabe / gmail.com wrote:
> But I believe it is never correct.
> (`(char*)` cast is ugly, I want change `cont->machine.stack_src` but not `th->machine.stack_start`, ruby should change the behaviour only when `FIBER_USE_NATIVE == 0`, and so on.)

I guess replacing "char *" with "uintptr_t" is appropriate for
pointer arithmetic:

```
diff --git a/thread_pthread.c b/thread_pthread.c
index 96723d4b17..9f9959e095 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -841,8 +841,9 @@ native_thread_init_stack(rb_thread_t *th)
 	size_t size;
 
 	if (get_stack(&start, &size) == 0) {
-	    th->ec.machine.stack_start = start;
-	    th->ec.machine.stack_maxsize = size;
+	    uintptr_t diff = (uintptr_t)start - (uintptr_t)&curr;
+	    th->ec.machine.stack_start = &curr;
+	    th->ec.machine.stack_maxsize = size - diff;
 	}
 #elif defined get_stack_of
 	if (!th->ec.machine.stack_maxsize) {
```

The above works for me as far as test_io.rb goes, but my Thriber
patch for [Feature #13618] still segfaults with
FIBER_USE_NATIVE==0, so I guess that is a separate bug I need
to fix...

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>