Deadlock falsely detected when using condition variables

I have a fragment of multi-threaded code using Ruby's Mutex and
ConditionVariable class, where it appears that the interpreter
is calling a deadlock incorrectly.

I'm using ruby 1.8.6 on Windows XP.

The code in question looks like this:

@mutex = Mutex.new
@condition = ConditionVariable.new

@mutex.synchronize {
  @condition.wait(@mutex) until @data_ready
  ... use data...
  @data_ready = false
}

And the producer thread says:

@mutex.synchronize {
  ... make data available...
  @data_ready = true
  @condition.signal
}

Now sometimes the call to synchronize in the producer cause a deadlock,
which shows the two threads to be both sleeping, one in the condition
wait, one in the producer's synchronise call.

This should never happen... the condition is meant to atomically release
the mutex as it goes to sleep.

Whats happening here folk?

Clifford Heath.

Whats happening here folk?

What patchlevel of 1.8.6 are you using ? 1.8.6-p0 is completely broken
w.r.t. thread support. 1.8.6 p36 and p110 are better.

Sylvain

Sylvain Joyeux wrote:

Whats happening here folk?

What patchlevel of 1.8.6 are you using ? 1.8.6-p0 is completely broken w.r.t. thread support. 1.8.6 p36 and p110 are better.

Craaap! It's patch -p0! How can such a fundamental thing be so catastrophically broken?
Are there no test suites? I've been blaming myself for three hours now...

Thanks for much for setting me straight... I'll get a new version right away.

Clifford Heath.

Clifford Heath wrote:

What patchlevel of 1.8.6 are you using ? 1.8.6-p0 is completely broken w.r.t. thread support. 1.8.6 p36 and p110 are better.

My ruby -v said p0, but the install actually came from the latest one-click
installer, which calls itself 186-25. I don't know what the -25 means, but
there seems to be no newer one-click installer.

Do I have to build the current ruby from source, or is there a newer
one-click installer?

Clifford Heath.