Issue #9222 has been reported by tmm1 (Aman Gupta).

----------------------------------------
Bug #9222: xmalloc usage during GC_START event can cause confusing assertion failure
https://bugs.ruby-lang.org/issues/9222

Author: tmm1 (Aman Gupta)
Status: Open
Priority: Low
Assignee: ko1 (Koichi Sasada)
Category: 
Target version: current: 2.1.0
ruby -v: ruby 2.1.0dev (2013-12-06 trunk 44022)
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


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);
     }




-- 
http://bugs.ruby-lang.org/