diff options
author | KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> | 2024-01-12 17:32:16 +1100 |
---|---|---|
committer | KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> | 2024-01-12 17:58:54 +1100 |
commit | 396e94666ba1646cb0fd1459eeae3f2e7ddd2658 (patch) | |
tree | 246d743ec71c97ed9fa98e82da12135b1da354a4 /thread_pthread.c | |
parent | 6af0f442c7d16ab526c0e6859aa97ff217b73f99 (diff) | |
download | ruby-396e94666ba1646cb0fd1459eeae3f2e7ddd2658.tar.gz |
Revert "Pass down "stack start" variables from closer to the top of the stack"
This reverts commit 4ba8f0dc993953d3ddda6328e3ef17a2fc2cbde5.
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index a6a6c9d127..6d2f55a957 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1964,7 +1964,7 @@ reserve_stack(volatile char *limit, size_t size) #undef ruby_init_stack void -ruby_init_stack(volatile void *addr) +ruby_init_stack(volatile VALUE *addr) { native_main_thread.id = pthread_self(); @@ -2049,7 +2049,7 @@ ruby_init_stack(volatile void *addr) {int err = (expr); if (err) {rb_bug_errno(#expr, err);}} static int -native_thread_init_stack(rb_thread_t *th, void *local_in_parent_frame) +native_thread_init_stack(rb_thread_t *th) { rb_nativethread_id_t curr = pthread_self(); @@ -2064,8 +2064,8 @@ native_thread_init_stack(rb_thread_t *th, void *local_in_parent_frame) size_t size; if (get_stack(&start, &size) == 0) { - uintptr_t diff = (uintptr_t)start - (uintptr_t)local_in_parent_frame; - th->ec->machine.stack_start = (uintptr_t)local_in_parent_frame; + uintptr_t diff = (uintptr_t)start - (uintptr_t)&curr; + th->ec->machine.stack_start = (VALUE *)&curr; th->ec->machine.stack_maxsize = size - diff; } } @@ -2185,19 +2185,8 @@ native_thread_create_dedicated(rb_thread_t *th) static void call_thread_start_func_2(rb_thread_t *th) { - /* Capture the address of a local in this stack frame to mark the beginning of the - machine stack for this thread. This is required even if we can tell the real - stack beginning from the pthread API in native_thread_init_stack, because - glibc stores some of its own data on the stack before calling into user code - on a new thread, and replacing that data on fiber-switch would break it (see - bug #13887) */ - VALUE stack_start = 0; - VALUE *stack_start_addr = &stack_start; - native_thread_init_stack(th, stack_start_addr); + native_thread_init_stack(th); thread_start_func_2(th, th->ec->machine.stack_start); - - /* Ensure that stack_start really was spilled to the stack */ - RB_GC_GUARD(stack_start) } static void * |