Bug #9222

xmalloc usage during GC_START event can cause confusing assertion failure

Added by Aman Gupta over 1 year ago. Updated over 1 year ago.

[ruby-core:58886]
Status:Closed
Priority:Normal
Assignee:Koichi Sasada
ruby -v:ruby 2.1.0dev (2013-12-06 trunk 44022) Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

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

Associated revisions

Revision 44166
Added by Koichi Sasada over 1 year ago

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

Revision 44166
Added by Koichi Sasada over 1 year ago

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

History

#1 Updated by Koichi Sasada over 1 year 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]

Also available in: Atom PDF