Actions
Bug #14578
closedForking a child process inside of a mutex crashes the ruby interpreter
Description
OS: Mac OS X 10.13.3 (High Sierra)
Affects ruby versions 2.5.0 and 2.6.0preview1
Issue not present in 2.4.1
Consider the following script. I contrived it as an experiment for a more complicated project. We have a resource that we want to synchronize access to, but we want to fork the process when actually using the resource. This script works in 2.4.1, but not in 2.5.0 or beyond.
class Synchronizer
def initialize
@mutex = Mutex.new
end
def use(&block)
@mutex.synchronize do
Process.fork do
block.call
end
Process.wait
end
end
end
@s = Synchronizer.new
5.times do |i|
Thread.new do
@s.use do
puts "block #{i}"
end
end
end
sleep 10
The error I get when the interpreter crashes is: [BUG] unexpected THREAD_KILLED
Is this a crazy implementation? Or a real bug?
Files
Actions
Like0
Like0Like0Like0Like0Like0