Project

General

Profile

Actions

Bug #17827

closed

Monitor is not fiber safe

Added by ioquatix (Samuel Williams) over 3 years ago. Updated about 2 years ago.

Status:
Closed
Target version:
-
[ruby-core:103591]

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

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #19105: mutex: Raise a ThreadError when detecting a fiber deadlockClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0