From: "luke-gru (Luke Gruber) via ruby-core" Date: 2023-02-01T13:38:13+00:00 Subject: [ruby-core:112170] [Ruby master Bug#19395] Process forking within non-main Ractor causes segv Issue #19395 has been updated by luke-gru (Luke Gruber). ruby -v set to 3.2.0 Ubuntu 22.04, the issue seems to be calling `rb_native_mutex_destroy` on a locked mutex in `ractor_free`. Relevant part of the backtrace: ``` /home/lukeg/.rbenv/versions/3.2.0/lib/libruby.so.3.2(die+0x0) [0x7fc1374d0e5f] /tmp/ruby-build.20230103230257.28392.jU9iPR/ruby-3.2.0/error.c:798 /home/lukeg/.rbenv/versions/3.2.0/lib/libruby.so.3.2(rb_bug) /tmp/ruby-build.20230103230257.28392.jU9iPR/ruby-3.2.0/error.c:800 /home/lukeg/.rbenv/versions/3.2.0/lib/libruby.so.3.2(rb_bug_errno+0x43) [0x7fc137579223] /tmp/ruby-build.20230103230257.28392.jU9iPR/ruby-3.2.0/error.c:829 /home/lukeg/.rbenv/versions/3.2.0/lib/libruby.so.3.2(rb_native_mutex_destroy+0x24) [0x7fc137719a24] /tmp/ruby-build.20230103230257.28392.jU9iPR/ruby-3.2.0/thread_pthread.c:603 /home/lukeg/.rbenv/versions/3.2.0/lib/libruby.so.3.2(ractor_free+0x11) [0x7fc137679991] /tmp/ruby-build.20230103230257.28392.jU9iPR/ruby-3.2.0/ractor.c:235 /home/lukeg/.rbenv/versions/3.2.0/lib/libruby.so.3.2(run_final+0xf) ``` If instead you change `exit 0` to `exec "date"`, it doesn't crash. Maybe the atfork hooks need to be changed to acquire locks in parent, unlock in child. ---------------------------------------- Bug #19395: Process forking within non-main Ractor causes segv https://bugs.ruby-lang.org/issues/19395#change-101606 * 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/