ActionsLike0
Bug #17827
closedMonitor is not fiber safe
Description
According to our discussion here https://github.com/rspec/rspec-support/issues/501 it seems like typical implementation of per-thread reentrant mutex is no longer valid and can lead to some deadlock situation.
#!/usr/bin/env ruby
require 'monitor'
def monitor_failure
m = Monitor.new
f1 = Fiber.new do
m.synchronize do
puts "f1 A"
Fiber.yield
puts "f1 B"
end
end
f2 = Fiber.new do
m.synchronize do
puts "f2 A"
# Fiber.yield
f1.resume
puts "f2 B"
end
end
f1.resume
f2.resume
end
monitor_failure
Added by Eregon (Benoit Daloze) almost 4 years ago
Added by nagachika (Tomoyuki Chikanaga) almost 4 years ago
merge revision(s) 3a3b19b2bba49e5d6f1cf13764eb6dd701397be9: [Backport #17827]
Fix Monitor to lock per Fiber, like Mutex [Bug #17827]
---
ext/monitor/monitor.c | 10 +++++-----
test/monitor/test_monitor.rb | 7 +++++++
2 files changed, 12 insertions(+), 5 deletions(-)
ActionsLike0
Fix Monitor to lock per Fiber, like Mutex [Bug #17827]