Bug #9222

xmalloc usage during GC_START event can cause confusing assertion failure

Added by Aman Gupta 5 months ago. Updated 4 months ago.

Assignee:Koichi Sasada
Target version: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 GCSTART, or raising a rbbug() on any attempt to re-enter the GC.

The only affects the GCSTART event, since it is fired in between duringgc++ and the assert().

1) Failure:
TestTracepointObj#testaftergcstarthookwithGCstress [test/-ext-/tracepoint/testtracepoint.rb:64]:

Expected /\A[1-9]/ to match "".

<[]> expected but was
<["Assertion failed: (duringgc > 0), function garbagecollect_body, file gc.c, line 4881."]>.

diff --git a/ext/-test-/tracepoint/gchook.c b/ext/-test-/tracepoint/gchook.c
index 6d8485e..9d95612 100644
--- a/ext/-test-/tracepoint/gchook.c
+++ b/ext/-test-/tracepoint/gc
@@ -32,6 +32,7 @@ gcstartendi(VALUE tpval, void *data)
fprintf(stderr, "trace: %s\n", rb
traceargeventflag(tparg) == RUBYINTERNALEVENTGCSTART ? "gcstart" : "gcend");

  • xfree(xmalloc(1)); if (invoking == 0) { rbpostponedjobregister(0, invokeproc, data); }

Associated revisions

Revision 44166
Added by Koichi Sasada 4 months ago

  • gc.c (garbagecollectbody): use rb_bug() and explicit error message instead of using assert(). [Bug #9222]


#1 Updated by Koichi Sasada 4 months 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 (garbagecollectbody): use rb_bug() and explicit error message instead of using assert(). [Bug #9222]

Also available in: Atom PDF