Bug #9222
closedxmalloc usage during GC_START event can cause confusing assertion failure
Description
You can reproduce the assertion failure with the following patch.
We should prevent this assert() from firing, either by ignoring GC requests during GC_START, or raising a rb_bug() on any attempt to re-enter the GC.
The only affects the GC_START event, since it is fired in between during_gc++ and the assert().
- Failure:
TestTracepointObj#test_after_gc_start_hook_with_GC_stress [test/-ext-/tracepoint/test_tracepoint.rb:64]:
Expected /\A[1-9]/ to match "".
<[]> expected but was
<["Assertion failed: (during_gc > 0), function garbage_collect_body, file gc.c, line 4881."]>.
diff --git a/ext/-test-/tracepoint/gc_hook.c b/ext/-test-/tracepoint/gc_hook.c
index 6d8485e..9d95612 100644
--- a/ext/-test-/tracepoint/gc_hook.c
+++ b/ext/-test-/tracepoint/gc_hook.c
@@ -32,6 +32,7 @@ gc_start_end_i(VALUE tpval, void *data)
fprintf(stderr, "trace: %s\n", rb_tracearg_event_flag(tparg) == RUBY_INTERNAL_EVENT_GC_START ? "gc_start" : "gc_end");
}
- xfree(xmalloc(1));
if (invoking == 0) {
rb_postponed_job_register(0, invoke_proc, data);
}
Updated by ko1 (Koichi Sasada) about 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44166.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- gc.c (garbage_collect_body): use rb_bug() and explicit error message
instead of using assert().
[Bug #9222]