Actions
Bug #20670
closedfork deadlocks in child process due to timer thread
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x86_64-linux]
Description
We've been seeing an occasional failure in the Rails CI related to a test which forks and I managed to reduce it to the following reproduction.
Thread.new do
loop { sleep 0.0001 }
end
1000.times do
pid = fork{}
Process.waitpid(pid)
rescue Exception
Process.kill(:KILL, pid)
raise
end
This hangs on Ruby 3.3 and HEAD (fairly reliably), but completes always on Ruby 3.2
In a debugger it seems like the timer thread acquires vm->ractor.sched.lock
in the parent process just as the process is forking. The child process then ends up stuck inside of thread_sched_atfork
when trying to acquire the same lock.
I've opened https://github.com/ruby/ruby/pull/11356 with a fix
Updated by jhawthorn (John Hawthorn) 3 months ago
- Related to Bug #19395: Process forking within non-main Ractor hits rb_bug() added
Updated by jhawthorn (John Hawthorn) 3 months ago
- Status changed from Open to Closed
- Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED
Updated by k0kubun (Takashi Kokubun) 2 months ago
- Backport changed from 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED to 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONE
ruby_3_3 66312ad913d67bfd3c2c83b174eabf537f5def84.
Actions
Like1
Like0Like1Like0Like0