bug involving condition variables
The following code generates a ThreadError ("not owner", raised in unlock_mutex_inner()). However, the ThreadError never gets reported at the top level (even though my code is re-raising it and Thread.abort_on_exception = true). A ThreadError that I raise directly gets reported normally.
For 1.8.6-p114 (Linux and Windows OCI), the output is:
#<ThreadError: not owner>
For 1.8.4, there is no output (so it looks like this difference has something to do with the thread rewrite in 1.8.6). See also ruby-talk:308103.
Thread.abort_on_exception = true
@q = 
@mutex = Mutex.new
@cond = ConditionVariable.new
def push(obj) @mutex.synchronize do @q << obj @cond.signal end end def pop @mutex.synchronize do if (email@example.com) return last end loop do @cond.wait(@mutex) if (firstname.lastname@example.org) return last end end end end
queue = MyQueue.new
#raise ThreadError, "foo bar"
# why does this behave differently than
# the "not owner" ThreadError ?
without the rescue clause the program has no exceptions--why?¶
rescue ThreadError => ex
raise ex # Why no exception reported at top level?