From: eregontp@... Date: 2021-04-26T22:02:13+00:00 Subject: [ruby-core:103602] [Ruby master Bug#17827] Monitor is not fiber safe Issue #17827 has been updated by Eregon (Benoit Daloze). As discussed on that linked issue (https://github.com/rspec/rspec-support/issues/501#issuecomment-826315195), the behavior should be the same as `Mutex` in this case, so it is a bug of the monitor stdlib. ---------------------------------------- Bug #17827: Monitor is not fiber safe https://bugs.ruby-lang.org/issues/17827#change-91696 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- 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 f2.resume end monitor_failure ``` -- https://bugs.ruby-lang.org/ Unsubscribe: