Skip to content

Commit d5e2779

Browse files
committed
Use rb_gc_get_ec in rb_gc_event_hook
This would allow rb_gc_event_hook to run in a GC thread that is a non-Ruby thread.
1 parent 203d127 commit d5e2779

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ rb_gc_event_hook(VALUE obj, rb_event_flag_t event)
239239
{
240240
if (LIKELY(!rb_gc_event_hook_required_p(event))) return;
241241

242-
rb_execution_context_t *ec = GET_EC();
242+
rb_execution_context_t *ec = rb_gc_get_ec();
243243
if (!ec->cfp) return;
244244

245245
EXEC_EVENT_HOOK(ec, event, ec->cfp->self, 0, 0, 0, obj);

gc/default/default.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6415,6 +6415,8 @@ garbage_collect(rb_objspace_t *objspace, unsigned int reason)
64156415
static int
64166416
gc_start(rb_objspace_t *objspace, unsigned int reason)
64176417
{
6418+
rb_gc_initialize_vm_context(&objspace->vm_context);
6419+
64186420
unsigned int do_full_mark = !!(reason & GPR_FLAG_FULL_MARK);
64196421

64206422
if (!rb_darray_size(objspace->heap_pages.sorted)) return TRUE; /* heap is not ready */

0 commit comments

Comments
 (0)