aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>2024-02-24 19:31:27 +1100
committerKJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>2024-03-25 14:57:04 +1100
commit48d3bdddbaeabed5fb6a97bfbe65e250d1383a9c (patch)
tree01073640401bd6cede2fdce1d285465c29d3eb7c
parentea31228d0c46763a62abef047d37d66709bdaf87 (diff)
downloadruby-48d3bdddbaeabed5fb6a97bfbe65e250d1383a9c.tar.gz
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]
-rw-r--r--gc.c2
-rw-r--r--thread.c3
-rw-r--r--thread_pthread.c1
-rw-r--r--vm_core.h9
4 files changed, 6 insertions, 9 deletions
diff --git a/gc.c b/gc.c
index eaa98928ff..07c0735a44 100644
--- a/gc.c
+++ b/gc.c
@@ -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
);
diff --git a/thread.c b/thread.c
index b8dd862634..e672172a4d 100644
--- a/thread.c
+++ b/thread.c
@@ -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 *
diff --git a/thread_pthread.c b/thread_pthread.c
index fb446eee82..cdaf6f240c 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -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) {
diff --git a/vm_core.h b/vm_core.h
index da1f568b66..805df18616 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -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