[Mono-dev] mono_thread_manage causes subsequent mono_jit_cleanup call to hang?

Vincent Povirk madewokherd at gmail.com
Wed Sep 10 18:29:37 UTC 2014


With a recent master build of Mono, I'm getting hangs in Wine when a
.NET exe exits. I think it's related to this commit:

commit 1996d664b4be7b97921485871f756db1d58011fe
Author: Rodrigo Kumpera <kumpera at gmail.com>
Date:   Mon Aug 25 14:37:22 2014 -0400

    [jit] Ensure no threads are running when the JIT is asked to cleanup.

Currently, our main function for running a .exe (_CorExeMain) exits by
doing this:

mono_thread_manage();
mono_jit_cleanup(domain);
return exit_code;

The hang is in the mono_jit_cleanup() call. I found that if I don't
call mono_thread_manage() first, it no longer hangs.

So that leads me to ask the following questions:

1. Is my use of mono_thread_manage correct? I thought it was my
responsibility to call this before mono_jit_cleanup, but that commit
seems to imply it's not my responsibility (but was still necessary in
all previous versions because Mono was broken).

2. Should Mono be fixed to account for what I was doing? I'd prefer to
have code that is as version-independent as possible. Maybe mono could
somehow detect that mono_thread_manage was already completed by the
current thread, and do nothing in this case?

3. Is there something else I can do on my end to fix this that won't
break with old Mono versions?


More information about the Mono-devel-list mailing list