From: "byroot (Jean Boussier)" Date: 2022-11-04T22:53:56+00:00 Subject: [ruby-core:110611] [Ruby master Bug#17827] Monitor is not fiber safe Issue #17827 has been updated by byroot (Jean Boussier). > It would be nice to raise a ThreadError when detecting in Mutex#lock that the Mutex is owned by the same Thread but a different Fiber, if there is no Fiber scheduler. I just ran into this issue, that would indeed be good to error out rather that deadlock forever. ---------------------------------------- Bug #17827: Monitor is not fiber safe https://bugs.ruby-lang.org/issues/17827#change-99943 * Author: ioquatix (Samuel Williams) * Status: Closed * Priority: Normal * Assignee: Eregon (Benoit Daloze) * Backport: 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE ---------------------------------------- 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 ``` -- https://bugs.ruby-lang.org/ Unsubscribe: