-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeout running condition variable signal_spec.rb #2340
Comments
Probably a duplicate of #1966 but I'm leaving it here because the error is slightly different and I want double the satisfaction for fixing it. 😃 |
I worked on this a bit this morning. I got a smaller reproduction of the issue, though it still takes about 5 minutes of repeatedly running with multiple processes to trigger the bug. I marked the place in the code where the thread never joins. m = Mutex.new
cv = ConditionVariable.new
repeats = 25
in_synchronize = false
t1 = Thread.new do
m.synchronize do
in_synchronize = true
repeats.times do
cv.wait(m)
cv.signal
end
end
end
# Make sure t1 is waiting for a signal before launching t2.
Thread.pass until in_synchronize
Thread.pass until t1.stop?
t2 = Thread.new do
m.synchronize do
repeats.times do
cv.signal
cv.wait(m)
end
end
end
puts 'stuck here?'
# Check that both threads terminated without exception
t1.join # <================================================== NEVER JOINS
puts 'stuck here?'
t2.join
p m.locked? |
With this code: m = Mutex.new
cv = ConditionVariable.new
repeats = 5
in_synchronize = false
t1 = Thread.new do
m.synchronize do
in_synchronize = true
repeats.times do
puts 't1 wait'
cv.wait(m)
puts 't1 signal'
cv.signal
end
end
end
# Make sure t1 is waiting for a signal before launching t2.
Thread.pass until in_synchronize
Thread.pass until t1.stop?
t2 = Thread.new do
m.synchronize do
repeats.times do
puts 't2 signal'
cv.signal
puts 't2 wait'
cv.wait(m)
end
end
end
puts 'stuck here?'
# Check that both threads terminated without exception
t1.join # <================================================== NEVER JOINS
puts 'stuck here?'
t2.join
#puts 'stuck here?'
p m.locked? When the process eventually hangs -- this took way longer to reproduce because all the printing seems to make it more stable -- it produces this output:
|
This is what is happening here. Thread 2 calls
|
The text was updated successfully, but these errors were encountered: