Project

General

Profile

Actions

Bug #22389

closed

Hang on GC.compact

Bug #22389: Hang on GC.compact

Added by rkh (Konstantin Haase) 21 days ago. Updated 20 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 4.1.0dev (2026-09-29T07:26:07Z master 64a4a372d7) +PRISM [arm64-darwin25]
[ruby-core:126879]

Description

The following code works on 4.0.7 but hangs on 4.1.0dev (64a4a372d7):

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:

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

Updated by eightbitraptor (Matt V-H) 20 days ago Actions #2

  • Status changed from Open to Closed

Applied in changeset git|e131720215251851efab1811a24c4d59a0fc979d.


Use pthread_sigmask in the GC read barrier signal handler

sigprocmask() is unspecified in multithreaded processes; on macOS it
left SIGSEGV/SIGBUS blocked on the faulting thread, so a second
read-barrier fault was never delivered and the process hung on the
faulting instruction. [Bug #22389]

Actions

Also available in: PDF Atom