Bug #13916
closedRace condition when sending a signal to a new fork
Description
To reproduce, run this script:
1_000_000.times do |i|
pid = fork {sleep}
puts pid
Process.kill(:TERM, pid)
Process.wait(pid)
end
Expected behavior: it should print a million pids and then exit.
Actual behavior: after some number of iterations, it freezes on the call to Process.wait
, because the fork never got killed by the TERM signal. (I verified with ps
that the pid it froze on is still running.)
Updated by normalperson (Eric Wong) over 7 years ago
russell.davis@gmail.com wrote:
Oops, I don't think we block signals properly for plain fork' (vs
spawn').
We need to use pthread_sigmask / sigprocmask to block signal.
I am testing this (slowly) and going to take a break while it
runs:
https://80x24.org/spew/20170919223250.22840-1-e@80x24.org/raw
Updated by Anonymous over 7 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r59975.
process: block/unblock signals around fork
As with forking for execve(2) in spawn', we must block signals to ensure they are handled correctly in a freshly
fork'-ed child.
-
process.c (retry_fork_ruby): block/unblock signals around fork
(rb_fork_ruby): re-enable signals in forked child -
test/ruby/test_process.rb (test_forked_child_signal): new test
[ruby-core:82883] [Bug #13916]Thanks to Russell Davis for the bug report and test case.
Updated by normalperson (Eric Wong) over 7 years ago
Eric Wong normalperson@yhbt.net wrote:
russell.davis@gmail.com wrote:
https://bugs.ruby-lang.org/issues/13916
https://80x24.org/spew/20170919223250.22840-1-e@80x24.org/raw
Cleaned up and added test, committed as r59975
Updated by normalperson (Eric Wong) over 7 years ago
- Status changed from Closed to Open
- Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED
backport status change
Updated by normalperson (Eric Wong) over 7 years ago
- Status changed from Open to Closed
closing to trigger backport of r59975
Updated by nagachika (Tomoyuki Chikanaga) almost 7 years ago
- Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE
ruby_2_4 r62665 merged revision(s) 59975.
Updated by usa (Usaku NAKAMURA) almost 7 years ago
- Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE to 2.2: REQUIRED, 2.3: DONE, 2.4: DONE
ruby_2_3 r62816 merged revision(s) 59975.