Project

General

Profile

Actions

Bug #11178

closed

possible bug: a thread killed when waiting on ConditionVariable locks the mutex again before real exit

Added by cvss (Kirill Vechera) almost 9 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:69352]

Description

Probably it's not a bug, but just a hidden behaviour. Please write your comments.

When a thread waits on ConditionVariable, it releases the mutex. And killing the thread during this state assumes no need to lock the mutex again because there's no ruby code to be executed. It results to problems:

  • the killed thread remains alive until the mutex is released by another thread
  • joining the killed thread from another thread locked on the mutex brings to deadlock
@m= Mutex.new
@r = ConditionVariable.new

t = Thread.new {
	@m.synchronize do
		@r.wait(@m)
	end
}

sleep 0.01

@m.synchronize do
	t.kill
	sleep 0.01
	puts "alive?: #{t.alive?}" # the thread should not be alive here
	t.join # at this point we're getting dealock
end


Files

1.rb (240 Bytes) 1.rb cvss (Kirill Vechera), 05/24/2015 09:23 PM
Actions

Also available in: Atom PDF

Like0
Like0