[Mono-dev] mono_jit_init fails when called from a Qt QThread

Frank Fuchs fk.fuchs at googlemail.com
Wed Aug 11 03:01:38 EDT 2010

thank you for the hint to mono_tread_attach. I should spend more time with
RTFM. Now using this I was able to get beyond the init and the attach but
crashed again at the creation of a seperate app_domain. While this might be
accepted, since I could create the app domain in the main thread as well I
finally got stuck with the following error upon  mono_domain_assembly_open
(not using app domains at all).

Program received signal SIGSEGV, Segmentation fault.

[Switching to process 17740]

0x00007fff870196d7 in pthread_mutex_lock ()

(gdb) where

#0  0x00007fff870196d7 in pthread_mutex_lock ()

#1  0x0000000100766b86 in mono_domain_assembly_open ()

#2  0x00000001000eae5d in ScriptEngineMono::ExecuteMain (this=0x1028b2250,
rFile=0x116e3f6d8 "/Users/fuchs/Scripts/auto.exe") at

#3  0x00000001000eb5a1 in ScriptEngineMono::CompileAndRun (this=0x1028b2250,
rSourcefiles={{p = {static shared_null = {ref = {_q_value = 3691}, alloc =
0, begin = 0, end = 0, sharable = 1, array = {0x0}}, d = 0x10287d3e0}, d =
0x10287d3e0}}) at ScriptEngine/ScriptEngineMono.cpp:168

#4  0x00000001000f5d5f in ScriptEngine::run (this=0x7fff5fbfdf90) at

#5  0x0000000101d1adaf in QThreadPrivate::start ()

#6  0x00007fff8704d456 in _pthread_start ()

#7  0x00007fff8704d309 in thread_start ()


> On 10.08.2010 22:00, Frank Fuchs wrote:
> >* Hi,
> *>* I think I have a rather special problem here. I have a Qt C++ application with an embedded mono jit.
> *>* Everything works nicely so far. However, I recently tried to start the Jit from a Qthread
> *>* (in order to have an unblocked GUI during the "C# script" execution, which can be several minutes).
> *>* Sadly I don't even get close to execution of the assembly, since the mono_jit_init_version call fails.
> *>* The stack trace provided by gdb is attached below. To me it looks like Qt does not play nice with pthreads as used by the GC.
> *>* (I found something similar using QThreads and openmp together.)
> *>* Any comments? Whose fault is it? I read something about the "new GC", would it cure this?
> *>*
> *>* BTW: system is Mac OS X 10.6.4 with mono 2.7 build from trunk.
> *
> Given that mono_jit_init() can't be called more than once per
> process, you could just call it from the main thread and forget
> about the issue after you've filed a bug at
> http://mono-project.com/Bugs :)
> The real work (compiling and executing your C# "scripts") can be
> performed from a separate thread, but don't forget to call
> mono_thread_attach(domain) from this thread.
> Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100811/5b3d7eb7/attachment.html 

More information about the Mono-devel-list mailing list