Move asan_fake_stack_handle to EC, not thread

It's really a property of the EC; each fiber (which has its own EC) also
has its own asan_fake_stack_handle.

[Bug #20310]
This commit is contained in:
KJ Tsanaktsidis 2024-02-24 19:31:27 +11:00
parent ea31228d0c
commit 48d3bdddba
4 changed files with 6 additions and 9 deletions

2
gc.c
View File

@ -6410,7 +6410,7 @@ gc_mark_machine_stack_location_maybe(rb_objspace_t *objspace, VALUE obj)
void *fake_frame_start;
void *fake_frame_end;
bool is_fake_frame = asan_get_fake_stack_extents(
ec->thread_ptr->asan_fake_stack_handle, obj,
ec->machine.asan_fake_stack_handle, obj,
ec->machine.stack_start, ec->machine.stack_end,
&fake_frame_start, &fake_frame_end
);

View File

@ -527,9 +527,6 @@ void
ruby_thread_init_stack(rb_thread_t *th, void *local_in_parent_frame)
{
native_thread_init_stack(th, local_in_parent_frame);
#ifdef RUBY_ASAN_ENABLED
th->asan_fake_stack_handle = asan_get_thread_fake_stack_handle();
#endif
}
const VALUE *

View File

@ -2081,6 +2081,7 @@ native_thread_init_stack(rb_thread_t *th, void *local_in_parent_frame)
rb_nativethread_id_t curr = pthread_self();
#ifdef RUBY_ASAN_ENABLED
local_in_parent_frame = asan_get_real_stack_addr(local_in_parent_frame);
th->ec->machine.asan_fake_stack_handle = asan_get_thread_fake_stack_handle();
#endif
if (!native_main_thread.id) {

View File

@ -1044,6 +1044,10 @@ struct rb_execution_context_struct {
VALUE *stack_end;
size_t stack_maxsize;
RUBY_ALIGNAS(SIZEOF_VALUE) jmp_buf regs;
#ifdef RUBY_ASAN_ENABLED
void *asan_fake_stack_handle;
#endif
} machine;
};
@ -1164,11 +1168,6 @@ typedef struct rb_thread_struct {
void **specific_storage;
struct rb_ext_config ext_config;
#ifdef RUBY_ASAN_ENABLED
void *asan_fake_stack_handle;
#endif
} rb_thread_t;
static inline unsigned int