Bug 1835 - crash with unreachable code / return from a method
Summary: crash with unreachable code / return from a method
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-11-02 11:24 UTC by Nicolas Antoniazzi
Modified: 2011-11-02 17:59 UTC (History)
2 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 Nicolas Antoniazzi 2011-11-02 11:24:38 UTC
There is a crash when running a simple code that throw an Exception.

Steps :

1 - Create a sample file (Test.cs) :
--------------------------
using System;

class A {
    public static bool myFunc() {
        bool a = true;
        if (a) throw new Exception();
        return true;
    }

    public static void Main(string[] args) {
        bool b = B.myFunc();
        Console.WriteLine(b);
    }
}
------------------------------
2 - compile it with : gmcs -debug -out:Test.exe Test.cs

3 - Executes it : mono --debug Test.exe

It crashes on mono 2.10.2 (compiled from source) and 2.10.5 (packaged in ubuntu 11.10)
It works on mono 2.6.7 (packaged in ubuntu 11.04)


When it crashes, the stack trace is :


* Assertion at mini-codegen.c:1186, condition `reginfo [sreg].born_in > 0' not met

Stacktrace:


Native stacktrace:

	/usr/bin/mono() [0x80e07cb]
	[0xb77af40c]
	/lib/i386-linux-gnu/libc.so.6(abort+0x17e) [0xb761934e]
	/usr/bin/mono() [0x8219a8e]
	/usr/bin/mono() [0x8219b0d]
	/usr/bin/mono() [0x80db4c2]
	/usr/bin/mono() [0x805e6e9]
	/usr/bin/mono() [0x805f757]
	/usr/bin/mono() [0x8061917]
	/usr/bin/mono() [0x80624ba]
	/usr/bin/mono(mono_runtime_invoke+0x3e) [0x81a6d5e]
	/usr/bin/mono(mono_runtime_exec_main+0xd8) [0x81a9a58]
	/usr/bin/mono(mono_main+0x1878) [0x80ba1b8]
	/usr/bin/mono() [0x805724e]
	/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0xb7601e37]
	/usr/mono/bin/mono() [0x80570a1]

Debug info from gdb:

Mono support loaded.
[Thread debugging using libthread_db enabled]
[New Thread 0xb67d4b70 (LWP 22138)]
[New Thread 0xb73e8b70 (LWP 22137)]
0xb77af424 in __kernel_vsyscall ()
  3 Thread 0xb73e8b70 (LWP 22137)  0xb77af424 in __kernel_vsyscall ()
  2 Thread 0xb67d4b70 (LWP 22138)  0xb77af424 in __kernel_vsyscall ()
* 1 Thread 0xb75eab60 (LWP 22136)  0xb77af424 in __kernel_vsyscall ()

Thread 3 (Thread 0xb73e8b70 (LWP 22137)):
#0  0xb77af424 in __kernel_vsyscall ()
#1  0xb775648c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/i386-linux-gnu/libpthread.so.0
#2  0x08231dd4 in GC_wait_marker () at pthread_support.c:1863
#3  0x0822a6e4 in GC_help_marker (my_mark_no=2) at mark.c:1116
#4  0x08230cbe in GC_mark_thread (id=0x0) at pthread_support.c:552
#5  0xb7751e99 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#6  0xb76bb73e in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 2 (Thread 0xb67d4b70 (LWP 22138)):
#0  0xb77af424 in __kernel_vsyscall ()
#1  0xb77587d5 in sem_wait@@GLIBC_2.1 () from /lib/i386-linux-gnu/libpthread.so.0
#2  0x08216390 in mono_sem_wait (sem=0x82f339c, alertable=1) at mono-semaphore.c:113
#3  0x08151b7e in finalizer_thread (unused=0x0) at gc.c:1066
#4  0x081d878e in start_wrapper_internal (data=0x9c7bc68) at threads.c:782
#5  start_wrapper (data=0x9c7bc68) at threads.c:830
#6  0x0820acdf in thread_start_routine (args=0x9ca1524) at wthreads.c:285
#7  0x08231a71 in GC_start_routine (arg=0x61fe0) at pthread_support.c:1468
#8  0xb7751e99 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#9  0xb76bb73e in clone () from /lib/i386-linux-gnu/libc.so.6

Thread 1 (Thread 0xb75eab60 (LWP 22136)):
#0  0xb77af424 in __kernel_vsyscall ()
#1  0xb775952b in read () from /lib/i386-linux-gnu/libpthread.so.0
#2  0x080e09a5 in read (signal=6, ctx=0xbf8806dc) at /usr/include/bits/unistd.h:45
#3  mono_handle_native_sigsegv (signal=6, ctx=0xbf8806dc) at mini-exceptions.c:2207
#4  <signal handler called>
#5  0xb77af424 in __kernel_vsyscall ()
#6  0xb7615e71 in raise () from /lib/i386-linux-gnu/libc.so.6
#7  0xb761934e in abort () from /lib/i386-linux-gnu/libc.so.6
#8  0x08219a8e in monoeg_g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=0x8241064 "* Assertion at %s:%d, condition `%s' not met\n", args=0xbf880b74 "\360\332$\b\242\004") at goutput.c:134
#9  0x08219b0d in monoeg_assertion_message (format=0x8241064 "* Assertion at %s:%d, condition `%s' not met\n") at goutput.c:154
#10 0x080db4c2 in mono_local_regalloc (cfg=0x9cd1a80, bb=0x9cd20d4) at mini-codegen.c:1186
#11 0x0805e6e9 in mono_codegen (cfg=0x9cd1a80) at mini.c:3594
#12 0x0805f757 in mini_method_compile (method="A:Main ()", opts=59861503, domain=0x34e58, run_cctors=1, compile_aot=0, parts=0) at mini.c:4860
#13 0x08061917 in mono_jit_compile_method_inner (method="A:Main ()", opt=59861503, ex=0xbf880f1c) at mini.c:5142
#14 mono_jit_compile_method_with_opt (method="A:Main ()", opt=59861503, ex=0xbf880f1c) at mini.c:5366
#15 0x080624ba in mono_jit_runtime_invoke (method="A:Main ()", obj=0x0, params=0xbf880f9c, exc=0x0) at mini.c:5586
#16 0x081a6d5e in mono_runtime_invoke (method="A:Main ()", obj=0x0, params=0xbf880f9c, exc=0x0) at object.c:2754
#17 0x081a9a58 in mono_runtime_exec_main (method="A:Main ()", args=0x3be00, exc=0x0) at object.c:3937
#18 0x080ba1b8 in main_thread_handler (argc=3, argv=0xbf881184) at driver.c:1003
#19 mono_main (argc=3, argv=0xbf881184) at driver.c:1855
#20 0x0805724e in mono_main_with_options (argc=3, argv=0xbf881184) at main.c:66
#21 main (argc=3, argv=0xbf881184) at main.c:97

=================================================================
Got a SIGABRT 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 Zoltan Varga 2011-11-02 17:59:57 UTC
Fixed in HEAD/mono-2-10 branch.