Issue #19395 has been updated by luke-gru (Luke Gruber).
This fixes it:
https://github.com/luke-gru/ruby/commit/0cb53d4458eb09d8a3f70caaa44c688b48b…
The issue is that when there's multiple ractors and you call fork, the other ractor(s)
that are in the child process that aren't the new main ractor need to be GC'd, and
their mutexes could be in a weird state, so either skip destruction of them or
reinitialize them in the child process. Re-init works on my machine but I don't know
if it works across platforms.
----------------------------------------
Bug #19395: Process forking within non-main Ractor hits rb_bug()
https://bugs.ruby-lang.org/issues/19395#change-101612
* Author: luke-gru (Luke Gruber)
* Status: Feedback
* Priority: Normal
* ruby -v: 3.2.0
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
```ruby
def test_fork_in_ractor
r2 = Ractor.new do
pid = fork do
exit Ractor.count
end
pid
end
pid = r2.take
puts "Process #{Process.pid} waiting for #{pid}"
_pid, status = Process.waitpid2(pid) # stuck forever
if status.exitstatus != 1
raise "status is #{status.exitstatus}"
end
end
test_fork_in_ractor()
```
$ top # shows CPU usage is high for child process
--
https://bugs.ruby-lang.org/