c5ab240ce3 (master): Fix ec NULL assertion failure during gc stress

0 views
Skip to first unread message

Matt Valentine-House

unread,
May 14, 2026, 5:27:29 AM (11 days ago) May 14
to ruby...@g.ruby-lang.org
Matt Valentine-House 2026-05-13 14:03:27 +0000 (Wed, 13 May 2026)

New Revision: c5ab240ce3

https://github.com/ruby/ruby/commit/c5ab240ce3

Log:
Fix ec NULL assertion failure during gc stress

rb_gc_initialize_vm_context calls GET_EC, which does VM_ASSERT(ec !=
NULL).

When Ruby is built with RUBY_DEBUG=1 and GC stress is set to run at boot
with RUBY_DEBUG=gc_stress then GC gets run inside Init_BareVM when we're
setting up the main_thread.

In gc_start we gate the GC with some early returns that prevent us
actually attempting a GC if the heap and objspace are not ready yet, but
we're attempting to initialize the gc's VM context before those gates,
causing the assertion to fail (because the VM isn't ready yet).

This commit moves the vm_context setup after the gates, so we don't
attempt it before objspace and the heap are fully set up.

To repro this bug configure with --enable-dev-env and
cflags=-DRUBY_DEBUG and then run

RUBY_DEBUG=gc_stress ./ruby -v

Modified files:
gc/default/default.c
Reply all
Reply to author
Forward
0 new messages