[ruby-core:126879] [Ruby Bug#22389] Hang on GC.compact
Issue #22389 has been reported by rkh (Konstantin Haase). ---------------------------------------- Bug #22389: Hang on GC.compact https://bugs.ruby-lang.org/issues/22389 * Author: rkh (Konstantin Haase) * Status: Open * ruby -v: ruby 4.1.0dev (2026-09-29T07:26:07Z master 64a4a372d7) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- The following code works on 4.0.7 but hangs on 4.1.0dev (64a4a372d7): ```ruby ready = Ractor::Port.new Ractor.new(ready) do |port| Array.new(10_000) { Object.new } port << true Ractor.receive end ready.receive Thread.new { GC.compact }.join GC.compact ``` A native sample of the hung process shows: ```text gc_start_global gc_compact_finish gc_update_references_heap rb_iseq_mark_and_move rb_gc_mark_and_move rb_gc_impl_location + 180 ``` -- https://bugs.ruby-lang.org/
Issue #22389 has been updated by eightbitraptor (Matt V-H). Thanks for the report. Fixed in [this PR](https://github.com/ruby/ruby/pull/19118) ---------------------------------------- Bug #22389: Hang on GC.compact https://bugs.ruby-lang.org/issues/22389#change-119251 * Author: rkh (Konstantin Haase) * Status: Open * ruby -v: ruby 4.1.0dev (2026-09-29T07:26:07Z master 64a4a372d7) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- The following code works on 4.0.7 but hangs on 4.1.0dev (64a4a372d7): ```ruby ready = Ractor::Port.new Ractor.new(ready) do |port| Array.new(10_000) { Object.new } port << true Ractor.receive end ready.receive Thread.new { GC.compact }.join GC.compact ``` A native sample of the hung process shows: ```text gc_start_global gc_compact_finish gc_update_references_heap rb_iseq_mark_and_move rb_gc_mark_and_move rb_gc_impl_location + 180 ``` -- https://bugs.ruby-lang.org/
Issue #22389 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: UNKNOWN, 3.4: DONE, 4.0: UNKNOWN ruby_3_4 commit:0b4e70bbd94ce4383b733860bd265dbf51764e6b merged revision(s) commit:e131720215251851efab1811a24c4d59a0fc979d. ---------------------------------------- Bug #22389: Hang on GC.compact https://bugs.ruby-lang.org/issues/22389#change-119897 * Author: rkh (Konstantin Haase) * Status: Closed * ruby -v: ruby 4.1.0dev (2026-09-29T07:26:07Z master 64a4a372d7) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: DONE, 4.0: UNKNOWN ---------------------------------------- The following code works on 4.0.7 but hangs on 4.1.0dev (64a4a372d7): ```ruby ready = Ractor::Port.new Ractor.new(ready) do |port| Array.new(10_000) { Object.new } port << true Ractor.receive end ready.receive Thread.new { GC.compact }.join GC.compact ``` A native sample of the hung process shows: ```text gc_start_global gc_compact_finish gc_update_references_heap rb_iseq_mark_and_move rb_gc_mark_and_move rb_gc_impl_location + 180 ``` -- https://bugs.ruby-lang.org/
Issue #22389 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: UNKNOWN, 3.4: DONE, 4.0: UNKNOWN to 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED After I backported for `[Bug #22467]`, the CI on macOS starts to hang-up. I suppose this change is also necessary. ---------------------------------------- Bug #22389: Hang on GC.compact https://bugs.ruby-lang.org/issues/22389#change-119898 * Author: rkh (Konstantin Haase) * Status: Closed * ruby -v: ruby 4.1.0dev (2026-09-29T07:26:07Z master 64a4a372d7) +PRISM [arm64-darwin25] * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED ---------------------------------------- The following code works on 4.0.7 but hangs on 4.1.0dev (64a4a372d7): ```ruby ready = Ractor::Port.new Ractor.new(ready) do |port| Array.new(10_000) { Object.new } port << true Ractor.receive end ready.receive Thread.new { GC.compact }.join GC.compact ``` A native sample of the hung process shows: ```text gc_start_global gc_compact_finish gc_update_references_heap rb_iseq_mark_and_move rb_gc_mark_and_move rb_gc_impl_location + 180 ``` -- https://bugs.ruby-lang.org/
Issue #22389 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_4_0 commit:fc954f71ce2004b36b307ceef679c93f3a3ac27f merged revision(s) commit:e131720215251851efab1811a24c4d59a0fc979d. ---------------------------------------- Bug #22389: Hang on GC.compact https://bugs.ruby-lang.org/issues/22389#change-119995 * Author: rkh (Konstantin Haase) * Status: Closed * ruby -v: ruby 4.1.0dev (2026-09-29T07:26:07Z master 64a4a372d7) +PRISM [arm64-darwin25] * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ---------------------------------------- The following code works on 4.0.7 but hangs on 4.1.0dev (64a4a372d7): ```ruby ready = Ractor::Port.new Ractor.new(ready) do |port| Array.new(10_000) { Object.new } port << true Ractor.receive end ready.receive Thread.new { GC.compact }.join GC.compact ``` A native sample of the hung process shows: ```text gc_start_global gc_compact_finish gc_update_references_heap rb_iseq_mark_and_move rb_gc_mark_and_move rb_gc_impl_location + 180 ``` -- https://bugs.ruby-lang.org/
participants (4)
-
eightbitraptor (Matt V-H) -
k0kubun (Takashi Kokubun) -
nagachika (Tomoyuki Chikanaga) -
rkh (Konstantin Haase)