Project

General

Profile

Actions

Bug #9222

closed

xmalloc usage during GC_START event can cause confusing assertion failure

Added by tmm1 (Aman Karmani) about 11 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.1.0dev (2013-12-06 trunk 44022)
[ruby-core:58886]

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().

  1. 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);
    }
Actions

Also available in: Atom PDF

Like0
Like0