Bug 36795 - bundled executable crash on startup
Summary: bundled executable crash on startup
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: pr0vieh
URL:
Depends on:
Blocks:
 
Reported: 2015-12-09 22:36 UTC by pr0vieh
Modified: 2016-10-19 04:22 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description pr0vieh 2015-12-09 22:36:20 UTC
mono -V
Mono JIT compiler version 4.3.0 (master/85c7bd0 Mi 9. Dez 21:23:07 CET 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  x86
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen

use mkbundle

OS is: Linux
Note that statically linking the LGPL Mono runtime has more licensing restrictions than dynamically linking.
See http://www.mono-project.com/Licensing for details on licensing.
WARNING:
  Check that the machine.config file you are bundling
  doesn't contain sensitive information specific to this machine.
Sources: 15 Auto-dependencies: True
 .
 .
 .
Compiling:
AS = as (default)
as -o temp.o temp.s 
CC = cc (default)
cc -o /myapp.exe -Wall `pkg-config --cflags mono-2` temp.c  `pkg-config --libs-only-L mono-2` -Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic `pkg-config --libs-only-l mono-2 | sed -e "s/\-lmono-2.0 //"` temp.o
Done

at startup
Native stacktrace:

	./myapp.exe() [0x82660bc]
	./myapp.exe() [0x8065031]
	[0xb77c7bd0]
	./myapp.exe() [0x81aeaf3]
	./myapp.exe() [0x81afdda]
	./myapp.exe() [0x827ecb6]
	./myapp.exe() [0x827ed07]
	./myapp.exe() [0x81aff33]
	./myapp.exe() [0x81acae7]
	./myapp.exe() [0x81a6456]
	./myapp.exe() [0x81a6074]
	./myapp.exe() [0x81b0a14]
	./myapp.exe() [0x81b0537]
	./myapp.exe() [0x80a643d]
	./myapp.exe() [0x80c3652]
	./myapp.exe() [0x80667d7]
	./myapp.exe() [0x805e477]
	./myapp.exe() [0x805d12f]
	/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xde) [0xb759072e]
	./myapp.exe() [0x805cd44]

Debug info from gdb:

[New LWP 2618]
[New LWP 2617]
[New LWP 2616]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
0xb77c7be8 in __kernel_vsyscall ()
  Id   Target Id         Frame 
  4    Thread 0xb7575b40 (LWP 2616) "MJ12nodeMono.ex" 0xb77c7be8 in __kernel_vsyscall ()
  3    Thread 0xb6d74b40 (LWP 2617) "MJ12nodeMono.ex" 0xb77c7be8 in __kernel_vsyscall ()
  2    Thread 0xb6573b40 (LWP 2618) "MJ12nodeMono.ex" 0xb77c7be8 in __kernel_vsyscall ()
* 1    Thread 0xb7576700 (LWP 2615) "MJ12nodeMono.ex" 0xb77c7be8 in __kernel_vsyscall ()

Thread 4 (Thread 0xb7575b40 (LWP 2616)):
#0  0xb77c7be8 in __kernel_vsyscall ()
#1  0xb773e25c in pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:187
#2  0x081b504a in GC_wait_marker () at pthread_support.c:1903
#3  0x081ae0f8 in GC_help_marker (my_mark_no=0) at mark.c:1116
#4  0x081b3984 in GC_mark_thread (id=0x0) at pthread_support.c:555
#5  0xb77391aa in start_thread (arg=0xb7575b40) at pthread_create.c:333
#6  0xb7661fde in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:122

Thread 3 (Thread 0xb6d74b40 (LWP 2617)):
#0  0xb77c7be8 in __kernel_vsyscall ()
#1  0xb773e25c in pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:187
#2  0x081b504a in GC_wait_marker () at pthread_support.c:1903
#3  0x081ae0f8 in GC_help_marker (my_mark_no=0) at mark.c:1116
#4  0x081b3984 in GC_mark_thread (id=0x1) at pthread_support.c:555
#5  0xb77391aa in start_thread (arg=0xb6d74b40) at pthread_create.c:333
#6  0xb7661fde in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:122

Thread 2 (Thread 0xb6573b40 (LWP 2618)):
#0  0xb77c7be8 in __kernel_vsyscall ()
#1  0xb773e25c in pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:187
#2  0x081b504a in GC_wait_marker () at pthread_support.c:1903
#3  0x081ae0f8 in GC_help_marker (my_mark_no=0) at mark.c:1116
#4  0x081b3984 in GC_mark_thread (id=0x2) at pthread_support.c:555
#5  0xb77391aa in start_thread (arg=0xb6573b40) at pthread_create.c:333
#6  0xb7661fde in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:122

Thread 1 (Thread 0xb7576700 (LWP 2615)):
#0  0xb77c7be8 in __kernel_vsyscall ()
#1  0xb774262b in waitpid () at ../sysdeps/unix/syscall-template.S:81
#2  0x08266189 in mono_handle_native_sigsegv (signal=11, ctx=0xbf8f0f8c, info=0xbf8f0f0c) at mini-exceptions.c:2235
#3  0x08065031 in mono_sigsegv_signal_handler (_dummy=11, _info=0xbf8f0f0c, context=0xbf8f0f8c) at mini-runtime.c:2490
#4  <signal handler called>
#5  GC_push_all_eager (bottom=0x0, top=0xbf8f1520 "") at mark.c:1468
#6  0x081afdda in GC_push_current_stack (cold_gc_frame=0xbf8f1520 "") at mark_rts.c:498
#7  0x0827ecb6 in GC_with_callee_saves_pushed (fn=0x81afdb1 <GC_push_current_stack>, arg=0xbf8f1520 "") at mach_dep.c:476
#8  0x0827ed07 in GC_generic_push_regs (cold_gc_frame=0xbf8f1520 "") at mach_dep.c:487
#9  0x081aff33 in GC_push_roots (all=1, cold_gc_frame=0xbf8f1520 "") at mark_rts.c:638
#10 0x081acae7 in GC_mark_some (cold_gc_frame=0xbf8f1520 "") at mark.c:326
#11 0x081a6456 in GC_stopped_mark (stop_func=0x81a5a57 <GC_never_stop_func>) at alloc.c:543
#12 0x081a6074 in GC_try_to_collect_inner (stop_func=0x81a5a57 <GC_never_stop_func>) at alloc.c:382
#13 0x081b0a14 in GC_init_inner () at misc.c:818
#14 0x081b0537 in GC_init () at misc.c:528
#15 0x080a643d in mono_gc_base_init () at boehm-gc.c:191
#16 0x080c3652 in mono_init_internal (filename=filename@entry=0x827f7c8 "myapp.exe", exe_filename=exe_filename@entry=0x827f7c8 "myapp.exe", runtime_version=runtime_version@entry=0x0) at domain.c:515
#17 0x080c485f in mono_init_from_assembly (domain_name=0x827f7c8 "myapp.exe", filename=0x827f7c8 "myapp.exe") at domain.c:900
#18 0x080667d7 in mini_init (filename=0x827f7c8 "myapp.exe", runtime_version=0x0) at mini-runtime.c:3160
#19 0x0805e477 in mono_main (argc=3, argv=0xb50f008) at driver.c:1953
#20 0x0805d12f in main ()

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
Comment 1 pr0vieh 2015-12-09 22:44:59 UTC
Use Linux 32bit

and at Linux 64bit this looks like this

@64bit  ../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.

Native stacktrace:

	./myapp.exe() [0x6230fa]
	./myapp.exe() [0x44e29c]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x10d10) [0x7f1c75862d10]
	./myapp.exe() [0x57b4a0]
	./myapp.exe() [0x57c9d4]
	./myapp.exe() [0x636edf]
	./myapp.exe() [0x636f36]
	./myapp.exe() [0x57cb20]
	./myapp.exe() [0x579023]
	./myapp.exe() [0x571eee]
	./myapp.exe() [0x571a59]
	./myapp.exe() [0x57d600]
	./myapp.exe() [0x57d167]
	./myapp.exe() [0x475825]
	./myapp.exe() [0x491ecc]
	./myapp.exe() [0x44f8de]
	./myapp.exe() [0x418163]
	./myapp.exe() [0x41707f]
	/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f1c75291a40]
	./myapp.exe() [0x416c39]

Debug info from gdb:

[New LWP 9578]
[New LWP 9577]
[New LWP 9576]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f1c758628ab in __waitpid (pid=pid@entry=9579, stat_loc=stat_loc@entry=0x7ffffd3cfd6c, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
40	../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
  Id   Target Id         Frame 
  4    Thread 0x7f1c75270700 (LWP 9576) "MJ12nodeMono.ex" pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
  3    Thread 0x7f1c74a6f700 (LWP 9577) "MJ12nodeMono.ex" pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
  2    Thread 0x7f1c7426e700 (LWP 9578) "MJ12nodeMono.ex" pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
* 1    Thread 0x7f1c76389740 (LWP 9575) "MJ12nodeMono.ex" 0x00007f1c758628ab in __waitpid (pid=pid@entry=9579, stat_loc=stat_loc@entry=0x7ffffd3cfd6c, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40

Thread 4 (Thread 0x7f1c75270700 (LWP 9576)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x0000000000581e6c in GC_wait_marker () at pthread_support.c:1903
#2  0x000000000057a953 in GC_help_marker (my_mark_no=0) at mark.c:1116
#3  0x00000000005807b1 in GC_mark_thread (id=0x0) at pthread_support.c:555
#4  0x00007f1c758596aa in start_thread (arg=0x7f1c75270700) at pthread_create.c:333
#5  0x00007f1c75377eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 3 (Thread 0x7f1c74a6f700 (LWP 9577)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x0000000000581e6c in GC_wait_marker () at pthread_support.c:1903
#2  0x000000000057a953 in GC_help_marker (my_mark_no=0) at mark.c:1116
#3  0x00000000005807b1 in GC_mark_thread (id=0x1) at pthread_support.c:555
#4  0x00007f1c758596aa in start_thread (arg=0x7f1c74a6f700) at pthread_create.c:333
#5  0x00007f1c75377eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 2 (Thread 0x7f1c7426e700 (LWP 9578)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x0000000000581e6c in GC_wait_marker () at pthread_support.c:1903
#2  0x000000000057a953 in GC_help_marker (my_mark_no=0) at mark.c:1116
#3  0x00000000005807b1 in GC_mark_thread (id=0x2) at pthread_support.c:555
#4  0x00007f1c758596aa in start_thread (arg=0x7f1c7426e700) at pthread_create.c:333
#5  0x00007f1c75377eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 1 (Thread 0x7f1c76389740 (LWP 9575)):
#0  0x00007f1c758628ab in __waitpid (pid=pid@entry=9579, stat_loc=stat_loc@entry=0x7ffffd3cfd6c, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
#1  0x00000000006231cc in mono_handle_native_sigsegv (signal=signal@entry=11, ctx=ctx@entry=0x7ffffd3d0700, info=info@entry=0x7ffffd3d0830) at mini-exceptions.c:2235
#2  0x000000000044e29c in mono_sigsegv_signal_handler (_dummy=11, _info=0x7ffffd3d0830, context=0x7ffffd3d0700) at mini-runtime.c:2490
#3  <signal handler called>
#4  GC_push_all_eager (bottom=0x0, top=0x7ffffd3d0e24 "") at mark.c:1468
#5  0x000000000057c9d4 in GC_push_current_stack (cold_gc_frame=0x7ffffd3d0e24 "") at mark_rts.c:498
#6  0x0000000000636edf in GC_with_callee_saves_pushed (fn=0x57c9aa <GC_push_current_stack>, arg=0x7ffffd3d0e24 "") at mach_dep.c:476
#7  0x0000000000636f36 in GC_generic_push_regs (cold_gc_frame=0x7ffffd3d0e24 "") at mach_dep.c:487
#8  0x000000000057cb20 in GC_push_roots (all=1, cold_gc_frame=0x7ffffd3d0e24 "") at mark_rts.c:638
#9  0x0000000000579023 in GC_mark_some (cold_gc_frame=0x7ffffd3d0e24 "") at mark.c:326
#10 0x0000000000571eee in GC_stopped_mark (stop_func=0x57133e <GC_never_stop_func>) at alloc.c:543
#11 0x0000000000571a59 in GC_try_to_collect_inner (stop_func=0x57133e <GC_never_stop_func>) at alloc.c:382
#12 0x000000000057d600 in GC_init_inner () at misc.c:818
#13 0x000000000057d167 in GC_init () at misc.c:528
#14 0x0000000000475825 in mono_gc_base_init () at boehm-gc.c:191
#15 0x0000000000491ecc in mono_init_internal (filename=filename@entry=0x6373b0 "myapp.exe", exe_filename=exe_filename@entry=0x6373b0 "myapp.exe", runtime_version=runtime_version@entry=0x0) at domain.c:515
#16 0x00000000004932c7 in mono_init_from_assembly (domain_name=domain_name@entry=0x6373b0 "myapp.exe", filename=filename@entry=0x6373b0 "myapp.exe") at domain.c:900
#17 0x000000000044f8de in mini_init (filename=0x6373b0 "myapp.exe", runtime_version=runtime_version@entry=0x0) at mini-runtime.c:3160
#18 0x0000000000418163 in mono_main (argc=3, argv=<optimized out>) at driver.c:1953
#19 0x000000000041707f in main ()

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
Comment 2 Aleksey Kliger 2015-12-22 20:33:27 UTC
Could you provide a sample program that demonstrates the issue?

I tried mj12node_linux_v1713.tgz from https://www.majestic12.co.uk/projects/dsearch/download.php on 32-bit Debian, using the commit of Mono from the bug report (85c7bd0) and built a static bundle using

  $ mkbundle --static -o myapp --deps MJ12nodeMono.exe MJ12commonLibMono.dll MJ12nodeLibMono.dll LZMA.dll edb_MySQLMono.dll ByteFX.MySqlClient.dll edb_SQLiteMono.dll System.Data.SQLite.dll

  $ ./myapp

worked as expected without a SEGV.
Comment 3 pr0vieh 2015-12-22 21:34:52 UTC
This problem exists only on Ubuntu 15.10
Ubuntu 15.04 works fine

Yesterday I tested Ubuntu 15.04 and it runs
it has to something do with the Ubuntu update
new gcc version ?

I do not know whether mono or Ubuntu related
I'll try a clean install ubuntu 15.10 and give feedback
Comment 4 pr0vieh 2015-12-22 23:05:16 UTC
with a clean install same issue Ubuntu 15.10 is not working :/
Ubuntu problem ?
Comment 5 Hin-Tak Leung 2016-01-12 17:41:19 UTC
Seem the same as the bug I just filed.

Bug 37619 - mkbundle's result sefault on start if linked with mono-2; linking against monosgen-2 is okay.

Can you modify the final link step to link with libmonosgen to see if it helps?
You need most of the save temp options of mkbundle, and split running mkbundle into two steps.
Comment 6 pr0vieh 2016-10-18 22:07:38 UTC
It seems fixed a while ago
working on Ubuntu 15.10 and 16.04 without problems

Thanks!
Comment 7 Hin-Tak Leung 2016-10-19 04:22:21 UTC
They renamed the libraries in mono 4.4 - sgen is now the default. See if that's the case in your 'fix'?

$ ls -ld /usr/lib*/*mono*
lrwxrwxrwx.  1 root root      18 Aug 29 11:27 /usr/lib64/libmono-2.0.so -> libmonosgen-2.0.so
lrwxrwxrwx.  1 root root      20 Aug 29 11:27 /usr/lib64/libmono-2.0.so.1 -> libmonosgen-2.0.so.1
lrwxrwxrwx.  1 root root      24 Aug 29 11:27 /usr/lib64/libmono-2.0.so.1.0.0 -> libmonosgen-2.0.so.1.0.0
lrwxrwxrwx.  1 root root      25 Aug 29 11:27 /usr/lib64/libmonoboehm-2.0.so -> libmonoboehm-2.0.so.1.0.0
lrwxrwxrwx.  1 root root      25 Aug 29 11:27 /usr/lib64/libmonoboehm-2.0.so.1 -> libmonoboehm-2.0.so.1.0.0
-rwxr-xr-x.  1 root root 3731744 Aug 29 11:29 /usr/lib64/libmonoboehm-2.0.so.1.0.0
lrwxrwxrwx.  1 root root      24 Aug 29 11:27 /usr/lib64/libmonosgen-2.0.so -> libmonosgen-2.0.so.1.0.0
lrwxrwxrwx.  1 root root      24 Aug 29 11:27 /usr/lib64/libmonosgen-2.0.so.1 -> libmonosgen-2.0.so.1.0.0
-rwxr-xr-x.  1 root root 3833424 Aug 29 11:29 /usr/lib64/libmonosgen-2.0.so.1.0.0