Re-initialize vm->ractor.sched.lock after fork
Previously under certain conditions it was possible to encounter a deadlock in the forked child process if ractor.sched.lock was held. Co-authored-by: Nathan Froyd <froydnj@gmail.com>
This commit is contained in:
parent
908305a297
commit
87a85550ed
Notes:
git
2024-08-13 18:52:41 +00:00
@ -75,3 +75,25 @@ assert_equal '[1, 2]', %q{
|
|||||||
end
|
end
|
||||||
}, '[ruby-dev:44005] [Ruby 1.9 - Bug #4950]'
|
}, '[ruby-dev:44005] [Ruby 1.9 - Bug #4950]'
|
||||||
|
|
||||||
|
assert_equal 'ok', %q{
|
||||||
|
def now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
||||||
|
|
||||||
|
Thread.new do
|
||||||
|
loop { sleep 0.0001 }
|
||||||
|
end
|
||||||
|
|
||||||
|
10.times do
|
||||||
|
pid = fork{ exit!(0) }
|
||||||
|
deadline = now + 1
|
||||||
|
until Process.waitpid(pid, Process::WNOHANG)
|
||||||
|
if now > deadline
|
||||||
|
Process.kill(:KILL, pid)
|
||||||
|
raise "failed"
|
||||||
|
end
|
||||||
|
sleep 0.001
|
||||||
|
end
|
||||||
|
rescue NotImplementedError
|
||||||
|
end
|
||||||
|
:ok
|
||||||
|
}, '[Bug #20670]'
|
||||||
|
|
||||||
|
@ -1556,6 +1556,7 @@ thread_sched_atfork(struct rb_thread_sched *sched)
|
|||||||
}
|
}
|
||||||
vm->ractor.sched.running_cnt = 0;
|
vm->ractor.sched.running_cnt = 0;
|
||||||
|
|
||||||
|
rb_native_mutex_initialize(&vm->ractor.sched.lock);
|
||||||
// rb_native_cond_destroy(&vm->ractor.sched.cond);
|
// rb_native_cond_destroy(&vm->ractor.sched.cond);
|
||||||
rb_native_cond_initialize(&vm->ractor.sched.cond);
|
rb_native_cond_initialize(&vm->ractor.sched.cond);
|
||||||
rb_native_cond_initialize(&vm->ractor.sched.barrier_complete_cond);
|
rb_native_cond_initialize(&vm->ractor.sched.barrier_complete_cond);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user