diff options
-rw-r--r-- | gc.c | 1 | ||||
-rw-r--r-- | test/objspace/test_ractor.rb | 17 |
2 files changed, 18 insertions, 0 deletions
@@ -2484,6 +2484,7 @@ rb_objspace_set_event_hook(const rb_event_flag_t event) static void gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data) { + if (UNLIKELY(!ec->cfp)) return; const VALUE *pc = ec->cfp->pc; if (pc && VM_FRAME_RUBYFRAME_P(ec->cfp)) { int prev_opcode = rb_vm_insn_addr2opcode((void *)*ec->cfp->iseq->body->iseq_encoded); diff --git a/test/objspace/test_ractor.rb b/test/objspace/test_ractor.rb new file mode 100644 index 0000000000..b7008ea731 --- /dev/null +++ b/test/objspace/test_ractor.rb @@ -0,0 +1,17 @@ +require "test/unit" + +class TestObjSpaceRactor < Test::Unit::TestCase + def test_tracing_does_not_crash + assert_ractor(<<~RUBY, require: 'objspace') + ObjectSpace.trace_object_allocations do + r = Ractor.new do + obj = 'a' * 1024 + Ractor.yield obj + end + + r.take + r.take + end + RUBY + end +end |