[Mono-osx] Bundled mono console application on OS X throwing gthread errors.

Geoff Norton gnorton at novell.com
Wed Nov 12 14:36:52 EST 2008


This error generally means you are somehow bringing two different
versions of glib into your project.

-g

On Wed, 2008-11-12 at 11:29 -0800, silver83 wrote:
> I can't expose the source code but I'll try to recreate the exception using
> some sample code and post it here later.
> 
> I have a mono console application (exe), that has assembly references to
> several manages dll's and exe's.
> Let's say the application directory looks like this :
> AppDir/App.exe
> AppDir/App.exe.config
> AppDir/RefAssembly.dll
> AppDir/Native/nativeLib1.dylib
> 
> Steps : 
> 1. Run "mkbundle2 -o App App.exe RefAssembly.dll". 
> 2. Run "macpack -a App.exe -m console -n BundledApp.app"
> 3. Move App (the result of mkbundle) and the Native folder 
>     to "BundledApp.app/Contents/Resources"
> 4. Replace BundledApp.app/Contents/MacOS/BundledApp" with a bash script that
> actually executes 
>     "BundledApp.app/Contents/App"
> 
> 5. Use otool -L on "BundledApp.app/Contents/App", find library references.
> 6. For each library reference 
> 6.1. copy it to "BundledApp.app/Contents/Libraries/". 
> 6.2. use install_name_tool to change the reference to
> "@executable_path/../Libraries/libname". 
> 6.3. use install_name_tool to change the install name of the library itself
> to same.
> 6.4. for this library reference, perform step 6 recursively on it (find it's
> references, etc...)
> 
> Step 6 is a c# application which excludes everything non-mono, similar to
> the one found here : 
> http://code.google.com/p/cocoa-sharp-dev/wiki/RedistributableAppWithoutInstallingMono
> 
> This leaves me with the following directory structure :
> BundledApp.app/Contents/Resources/App
> BundledApp.app/Contents/Resources/Native/nativeLib1.dylib
> BundledApp.app/Contents/Libraries/libglib-2.0.0.1800.1.dylib
> BundledApp.app/Contents/Libraries/	libgthread-2.0.0.1800.1.dylib	
> BundledApp.app/Contents/Libraries/libmono.0.0.0.dylib
> BundledApp.app/Contents/Libraries/libglib-2.0.0.dylib
> BundledApp.app/Contents/Libraries/libintl.8.0.2.dylib
> 
> Here is the tool -L result of all of them now :
> 
> ./libglib-2.0.0.1800.1.dylib:
> 	@executable_path/../Libraries/libglib-2.0.0.1800.1.dylib (compatibility
> version 1801.0.0, current version 1801.1.0)
> 	/usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version
> 5.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 88.3.10)
> 	@executable_path/../Libraries/libintl.8.0.2.dylib (compatibility version
> 9.0.0, current version 9.2.0)
> 	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
> (compatibility version 2.0.0, current version 128.0.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
> 1.0.0)
> ./libglib-2.0.0.dylib:
> 	@executable_path/../Libraries/libglib-2.0.0.dylib (compatibility version
> 1801.0.0, current version 1801.1.0)
> 	/usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version
> 5.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 88.3.10)
> 	@executable_path/../Libraries/libintl.8.0.2.dylib (compatibility version
> 9.0.0, current version 9.2.0)
> 	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
> (compatibility version 2.0.0, current version 128.0.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
> 1.0.0)
> ./libgthread-2.0.0.1800.1.dylib:
> 	@executable_path/../Libraries/libgthread-2.0.0.1800.1.dylib (compatibility
> version 1801.0.0, current version 1801.1.0)
> 	@executable_path/../Libraries/libglib-2.0.0.dylib (compatibility version
> 1801.0.0, current version 1801.1.0)
> 	/usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version
> 5.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 88.3.10)
> 	@executable_path/../Libraries/libintl.8.0.2.dylib (compatibility version
> 9.0.0, current version 9.2.0)
> 	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
> (compatibility version 2.0.0, current version 128.0.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
> 1.0.0)
> ./libintl.8.0.2.dylib:
> 	@executable_path/../Libraries/libintl.8.0.2.dylib (compatibility version
> 9.0.0, current version 9.2.0)
> 	/usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version
> 5.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 88.3.10)
> 
> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
> (compatibility version 150.0.0, current version 368.35.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
> 1.0.0)
> ./libmono.0.0.0.dylib:
> 	@executable_path/../Libraries/libmono.0.0.0.dylib (compatibility version
> 1.0.0, current version 1.0.0)
> 	@executable_path/../Libraries/libgthread-2.0.0.1800.1.dylib (compatibility
> version 1801.0.0, current version 1801.1.0)
> 	/usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version
> 5.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 88.3.10)
> 	@executable_path/../Libraries/libglib-2.0.0.1800.1.dylib (compatibility
> version 1801.0.0, current version 1801.1.0)
> 	@executable_path/../Libraries/libintl.8.0.2.dylib (compatibility version
> 9.0.0, current version 9.2.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
> 1.0.0)
> 
> /Resources/App:
> 	@executable_path/../Libraries/libmono.0.0.0.dylib (compatibility version
> 1.0.0, current version 1.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 111.1.1)
> 	@executable_path/../Libraries/libgthread-2.0.0.1800.1.dylib (compatibility
> version 1801.0.0, current version 1801.1.0)
> 	@executable_path/../Libraries/libglib-2.0.0.1800.1.dylib (compatibility
> version 1801.0.0, current version 1801.1.0)
> 	@executable_path/../Libraries/libintl.8.0.2.dylib (compatibility version
> 9.0.0, current version 9.2.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
> 1.0.0)
> 
> 
> And voila, from a working app, you got a bundled app that doesn't work and
> throws the exception I stated in previous posts.
> 
> I'd digging into this, and I found that although all the file references are
> processes correctly by dyld, there is a duplicate gthread init call which
> causes the crash. I'll dtrace this tommorow and post the stack traces of
> both calls.
> 
> Thanks for the help so far. 
> 
> 
> duanew wrote:
> > 
> > It is too vague (to me anyway) what you are actually doing... you might
> > try
> > posting the code as well as the steps involving mkbundle,
> > install_name_tool,
> > etc.
> > 
> > On Wed, Nov 12, 2008 at 11:43 AM, silver83 <silver83 at gmail.com> wrote:
> > 
> >>
> >> I still couldn't get it to work, using either @install_path or @rpath
> >> techniques...
> >> Still getting gthread error :
> >> GThread-ERROR **: GThread system may only be initialized once.
> >>
> >> 0   libSystem.B.dylib                   0x95123b9e __kill + 10
> >> 1   libSystem.B.dylib                   0x9519aec2 raise + 26
> >> 2   libSystem.B.dylib                   0x951aa47f abort + 73
> >> 3   libglib-2.0.0.dylib                 0x00e81ecc g_log + 0
> >> 4   libglib-2.0.0.dylib                 0x00e81ef5 g_log + 41
> >> 5   libgthread-2.0.0.1800.1.dylib       0x0000e3d7 g_thread_init + 521
> >> 6   libmono.0.0.0.dylib                 0x0073233d mini_init + 2968
> >> (mini.c:14091)
> >> 7   libmono.0.0.0.dylib                 0x00778a63 mono_main + 454
> >> (driver.c:1445)
> >> 8   LiboxEngine                         0x00001fd0 main + 215
> >> 9   LiboxEngine                         0x00001e7a start + 54
> >>
> >> Help ??
> >>
> >>
> >>
> >> duanew wrote:
> >> >
> >> > I had a similar need.  I wanted to fully embed mono within my
> >> application
> >> > so
> >> > the end user did not need to install mono.  I posted here:
> >> > http://lists.ximian.com/pipermail/mono-osx/2008-October/001616.html
> >> >
> >> > which describes the steps I went through.  Two differences in my post,
> >> one
> >> > is that I was using a DLL.  But now I use an EXE and have essentially
> >> the
> >> > same workflow.  Two, I embedded my mono app into a Cocoa application.
> >> >
> >> > I do not think you need that nant code referenced in the link in your
> >> > post.
> >> > You can download monobjc and look how their make system handles
> >> mkbundle.
> >> > I
> >> > started there and was able to pull out the necessary steps.  Monobjc
> >> has
> >> a
> >> > very ellegant build system that is a greating starting point.
> >> >
> >> > Best of luck,
> >> > Duane
> >> >
> >> > On Tue, Nov 11, 2008 at 6:48 AM, silver83 <silver83 at gmail.com> wrote:
> >> >
> >> >>
> >> >> I have bundled a mono console application using the following steps :
> >> >> 1. use mkbundle to create the binary
> >> >> 2. use macpack to create a dummy .app
> >> >> 3. inject the bundled binary into the .app's resources folder
> >> >> 4. rewire the execution script and the files under /Resources to
> >> execute
> >> >> the
> >> >> binary
> >> >>
> >> >> I run the application and everything is fine, but now I want to rewire
> >> >> library dependencies -
> >> >> I'm using code from :
> >> >>
> >> >>
> >> >>
> >> http://code.google.com/p/cocoa-sharp-dev/wiki/RedistributableAppWithoutInstallingMono
> >> >>
> >> >> to inject mono libraries into Resources folder, rewire my app to use
> >> >> them,
> >> >> and rewire them to use themselves (using otool -L to see their
> >> >> dependencies,
> >> >> and install_name_tool to rewire them).
> >> >>
> >> >> During rewiring, I exclude things that I consider "non-mono" -
> >> >> CoreFoundation, Carbon, libgcc, and libSystem.  I've tried several
> >> >> mixtures
> >> >> of which libraries to exclude, and I either end up with a
> >> mono-dependent
> >> >> application, or an application that crashed on :
> >> >>
> >> >> GThread-ERROR **: GThread system may only be initialized once.
> >> >>
> >> >> Some of the crash report :
> >> >> Exception Type:  EXC_CRASH (SIGABRT)
> >> >> Exception Codes: 0x0000000000000000, 0x0000000000000000
> >> >> Crashed Thread:  0
> >> >>
> >> >> Thread 0 Crashed:
> >> >> 0   libSystem.B.dylib                   0x95123b9e __kill + 10
> >> >> 1   libSystem.B.dylib                   0x9519aec2 raise + 26
> >> >> 2   libSystem.B.dylib                   0x951aa47f abort + 73
> >> >> 3   libglib-2.0.0.dylib                 0x00c00ecc g_log + 0
> >> >> 4   libglib-2.0.0.dylib                 0x00c00ef5 g_log + 41
> >> >> 5   libgthread-2.0.0.1800.1.dylib       0x009ec3d7 g_thread_init + 521
> >> >> 6   libmono.0.0.0.dylib                 0x002c933d mini_init + 2968
> >> >> (mini.c:14091)
> >> >> 7   libmono.0.0.0.dylib                 0x0030fa63 mono_main + 454
> >> >> (driver.c:1445)
> >> >> 8   MyApp                         0x00001f62 main + 215
> >> >> 9   MyApp                         0x00001df2 start + 54
> >> >>
> >> >> Thread 0 crashed with X86 Thread State (32-bit):
> >> >>  eax: 0x00000000  ebx: 0x951aa43f  ecx: 0xbffff47c  edx: 0x95123b9e
> >> >>  edi: 0x00000002  esi: 0x00d08010  ebp: 0xbffff498  esp: 0xbffff47c
> >> >>
> >> >>
> >> >> Any help (clues, hints, things I can do to debug this, maybe dtrace or
> >> >> something) - would be much appreciated...
> >> >>
> >> >> Thanks in advance
> >> >> Yoni.
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Bundled-mono-console-application-on-OS-X-throwing-gthread-errors.-tp20437966p20437966.html
> >> >> Sent from the Mono - OSX mailing list archive at Nabble.com.
> >> >>
> >> >> _______________________________________________
> >> >> Mono-osx mailing list
> >> >> Mono-osx at lists.ximian.com
> >> >> http://lists.ximian.com/mailman/listinfo/mono-osx
> >> >>
> >> >
> >> > _______________________________________________
> >> > Mono-osx mailing list
> >> > Mono-osx at lists.ximian.com
> >> > http://lists.ximian.com/mailman/listinfo/mono-osx
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Bundled-mono-console-application-on-OS-X-throwing-gthread-errors.-tp20437966p20464171.html
> >> Sent from the Mono - OSX mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> Mono-osx mailing list
> >> Mono-osx at lists.ximian.com
> >> http://lists.ximian.com/mailman/listinfo/mono-osx
> >>
> > 
> > _______________________________________________
> > Mono-osx mailing list
> > Mono-osx at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-osx
> > 
> > 
> 



More information about the Mono-osx mailing list