mirror of
https://github.com/ruby/ruby.git
synced 2026-11-08 01:20:26 +08:00
GC.start runs even while GC is disabled, so mmtk_handle_user_collection_request enables GC around the collection and disables it again afterward. While GC is enabled, another Ractor's GC.start can request a GC that hasn't run yet when this thread tries to re-disable GC. disable_collection fails in that state, and we panicked with "failed to re-disable GC after GC". This showed up as an intermittent crash of test_ractor_nt_switch.rb's gc_finalize_deferred test on the MMTk CI. Instead of panicking, block for the pending GC and try again. Since a GC is already requested, the retry joins it instead of starting a new one. https://github.com/ruby/mmtk/commit/3c6c503c50