Bug 41731 - mkbundled "Hello world" SEGVs in GC_push_all_eager
Summary: mkbundled "Hello world" SEGVs in GC_push_all_eager
Status: VERIFIED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: 4.2.0 (C6)
Hardware: PC Linux
: Normal normal
Target Milestone: 4.6.0 (C8)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-06-11 14:54 UTC by Mirco Bauer
Modified: 2016-08-30 09:30 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:
VERIFIED FIXED

Description Mirco Bauer 2016-06-11 14:54:36 UTC
When I used mkbundle the resulting binary will always crash on start with a SEGV.

The used Mono version is 4.2.1.102 on Linux/AMD64

meebey@redhorse:~$ cat test.cs
public class MainClass {
	static void Main() {
        System.Console.WriteLine("Hello world");
	}
}
meebey@redhorse:~$ dmcs test.cs
warning CS8001: SDK path could not be resolved
Compilation succeeded - 1 warning(s)
meebey@redhorse:~$ mono test.exe
Hello world
meebey@redhorse:~$ mkbundle --static test.exe
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.
Sources: 1 Auto-dependencies: False
   embedding: /home/meebey/test.exe
Compiling:
as -o temp.o temp.s 
cc -o a.out -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
meebey@redhorse:~$ ./a.out 

Native stacktrace:

	./a.out() [0x60dcba]
	./a.out() [0x44ec6c]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x10d40) [0x7f11c8e86d40]
	./a.out() [0x56be10]
	./a.out() [0x61f958]
	./a.out() [0x56d30f]
	./a.out() [0x56c6d8]
	./a.out() [0x5648b8]
	./a.out() [0x56519f]
	./a.out() [0x56e23a]
	./a.out() [0x56e35e]
	./a.out() [0x478205]
	./a.out() [0x493b0c]
	./a.out() [0x45005e]
	./a.out() [0x417773]
	./a.out() [0x41668b]
	/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f11c8af25f0]
	./a.out() [0x416259]

Debug info from gdb:

[New LWP 30282]
[New LWP 30281]
[New LWP 30280]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f11c8e8699b in __waitpid (pid=30283, stat_loc=0x7fffd8d6c06c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
29	../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
  Id   Target Id         Frame 
  4    Thread 0x7f11c87ce700 (LWP 30280) "a.out" pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
  3    Thread 0x7f11c7fcd700 (LWP 30281) "a.out" pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
  2    Thread 0x7f11c77cc700 (LWP 30282) "a.out" pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
* 1    Thread 0x7f11c997b740 (LWP 30279) "a.out" 0x00007f11c8e8699b in __waitpid (pid=30283, stat_loc=0x7fffd8d6c06c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29

Thread 4 (Thread 0x7f11c87ce700 (LWP 30280)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00000000005716c7 in GC_wait_marker ()
#2  0x000000000056b7da in GC_help_marker ()
#3  0x000000000056fd94 in GC_mark_thread ()
#4  0x00007f11c8e7d464 in start_thread (arg=0x7f11c87ce700) at pthread_create.c:334
#5  0x00007f11c8bbae5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 3 (Thread 0x7f11c7fcd700 (LWP 30281)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00000000005716c7 in GC_wait_marker ()
#2  0x000000000056b7da in GC_help_marker ()
#3  0x000000000056fd94 in GC_mark_thread ()
#4  0x00007f11c8e7d464 in start_thread (arg=0x7f11c7fcd700) at pthread_create.c:334
#5  0x00007f11c8bbae5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 2 (Thread 0x7f11c77cc700 (LWP 30282)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00000000005716c7 in GC_wait_marker ()
#2  0x000000000056b7da in GC_help_marker ()
#3  0x000000000056fd94 in GC_mark_thread ()
#4  0x00007f11c8e7d464 in start_thread (arg=0x7f11c77cc700) at pthread_create.c:334
#5  0x00007f11c8bbae5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 1 (Thread 0x7f11c997b740 (LWP 30279)):
#0  0x00007f11c8e8699b in __waitpid (pid=30283, stat_loc=0x7fffd8d6c06c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1  0x000000000060dd8c in mono_handle_native_sigsegv ()
#2  0x000000000044ec6c in mono_sigsegv_signal_handler ()
#3  <signal handler called>
#4  0x000000000056be10 in GC_push_all_eager ()
#5  0x000000000061f958 in GC_with_callee_saves_pushed ()
#6  0x000000000056d30f in GC_push_roots ()
#7  0x000000000056c6d8 in GC_mark_some ()
#8  0x00000000005648b8 in GC_stopped_mark ()
#9  0x000000000056519f in GC_try_to_collect_inner ()
#10 0x000000000056e23a in GC_init_inner ()
#11 0x000000000056e35e in GC_init ()
#12 0x0000000000478205 in mono_gc_base_init ()
#13 0x0000000000493b0c in mono_init_internal ()
#14 0x000000000045005e in mini_init ()
#15 0x0000000000417773 in mono_main ()
#16 0x000000000041668b 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.
=================================================================

Aborted
meebey@redhorse:~$
Comment 1 Mirco Bauer 2016-06-11 15:15:56 UTC
After cherry-picking this fix the SEGV went away:
https://github.com/mono/mono/commit/cd293cc37ac7a85b139177455a5927bdf3b05119

meebey@redhorse:~$ mkbundle --static test.exe
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.
Sources: 1 Auto-dependencies: False
   embedding: /home/meebey/test.exe
Compiling:
as -o temp.o temp.s 
cc -o a.out -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
meebey@redhorse:~$ ./a.out 
Hello world
meebey@redhorse:~$
Comment 2 Alex Rønne Petersen 2016-08-29 08:54:12 UTC
Resolving as fixed per comment #1.
Comment 3 Shruti 2016-08-30 09:30:46 UTC
As per Comment #1 and Comment #2 I am verifying this issue.

Thanks!