[Mono-dev] System.Threading.Monitor::Exit fails in latest trees

Martin Daeumler mdae at cs.tu-chemnitz.de
Fri Apr 29 09:39:54 EDT 2011


On March 10, 2010, Paolo Molaro wrote:

>> Further, I traced it down into the mono 2.6.1 code tree, and
>> mono_monitor_exit is never called. The trampoline generates the code, but
>> it's never called. Can you provide a quick fix? It seems like a glaring
>> bug.

>There is no bug, on your architecture the fast path is optimized and it
>won't go to the unmanaged function in the runtime.

Hello,

how does this fast path work on x86 and Mono 2.6.1? During JITing this code:

class Test {
	int test1;
	
	public int callInst(Test myClass) {
		lock (this) {
			myClass.test1 = 1;
		}
		return myClass.test1;
	}
	
	static int Main() {
		Test meineKlasse = new Test();		
		int ret = meineKlasse.callInst(meineKlasse);		
		Console.WriteLine("meineKlasse: " + ret.ToString());
		return 0;
	}
}

, "mono_monitor_get_fast_enter_method()" and
"mono_monitor_get_fast_exit_method()"
are not called. While executing the method "callInst()" the unmanaged
function
"mono_monitor_enter()" (mono/metadata/monitor.c) is called through a generic
trampoline.

Q1: The generic (monitor) trampoline is not called directly by the code of
"callInst()".
There is a kind of wrapper that calls the generic trampoline. Where is the
wrapper
generated?

When leaving the lock-block, i.e., calling
"System.Threading.Monitor::Exit()" from within
the finally-block in den CIL-code, the unmanaged function
"mono_monitor_exit()"
(mono/metadata/monitor.c) is not called at all. There is an ominous piece of
code that
returns to "callInst()".

Q2: How is the monitor exit fast path realized? Where is the "wrapper"
generated
which does not call "mono_monitor_exit()"?


With kind regards,
Martin Däumler

--
View this message in context: http://mono.1490590.n4.nabble.com/System-Threading-Monitor-Exit-fails-in-latest-trees-tp1578116p3483712.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list