[Ironruby-core] Problems with Mutex and ConditionVariable under IronRuby

Daniele Alessandri suppakilla at gmail.com
Fri Jan 2 07:35:15 EST 2009


I was playing with threads under IronRuby but it seems like I have
stumbled on problems with Mutex and ConditionVariable. At first I
thought the problem was related to my code even if it actually worked
flawlessy for months under MRI 1.8.6 and it runs fine under the latest
JRuby, so I tried to run the most basic example of using these two
classes (a classic one:
http://www.rubycentral.com/pickaxe/tut_threads.html#UF) but the
problems still persist.

At first I thought it was some kind of deadlock given that the output
obtained by running the code with ir.exe is as follows:

C:\Sviluppo\ironruby\SVN\trunk\build\debug>ir T002.rb
A: I have critical section, but will wait for cv
(Later, back at the ranch...)
B: Now I am critical, but am done with cv

(note that the process remains stuck there)

So I went debugging with Visual Studio and this is what I got in the
output window:

To make it short, the reported exception is thrown when the ruby code
calls ConditionVariable#signal and IronRuby internally calls
Monitor.Pulse on the Mutex instance:

public static RubyConditionVariable/*!*/
Signal(RubyConditionVariable/*!*/ self) {
    RubyMutex m = self._mutex;
    if (m != null) {
    return self;

It seems like the Monitor is not aware of being in a synchronized
block of code (or is not in a critical section at all). Any clues?



Daniele Alessandri

More information about the Ironruby-core mailing list