diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2026-05-08 18:02:12 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2026-05-08 19:33:02 -0400 |
| commit | 5faeea873ba4249c685c7f390e939560d736fea8 (patch) | |
| tree | 8f6b1cc1bcb73ec4e9027586c80d4ba3e991eb75 | |
| parent | e9e4647e6667743e26db037beaa6a56bc8c70f48 (diff) | |
Set EC in rb_gc_event_hook
The event hook may use the EC and it will be null when it is running from
a GC thread.
| -rw-r--r-- | gc.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -242,7 +242,30 @@ rb_gc_event_hook(VALUE obj, rb_event_flag_t event) rb_execution_context_t *ec = rb_gc_get_ec(); if (!ec->cfp) return; +#if USE_MODULAR_GC + bool gc_thread_p = false; + if (!GET_EC()) { + gc_thread_p = true; + +# ifdef RB_THREAD_LOCAL_SPECIFIER + rb_current_ec_set(ec); +# else + native_tls_set(ruby_current_ec_key, ec); +# endif + } +#endif + EXEC_EVENT_HOOK(ec, event, ec->cfp->self, 0, 0, 0, obj); + +#if USE_MODULAR_GC + if (gc_thread_p) { +# ifdef RB_THREAD_LOCAL_SPECIFIER + rb_current_ec_set(NULL); +# else + native_tls_set(ruby_current_ec_key, NULL); +# endif + } +#endif } void * |
