Bug 25684 - LLVM: Mono crashes on exceptions
Summary: LLVM: Mono crashes on exceptions
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-01-02 11:01 UTC by computerzerstoerer
Modified: 2015-01-02 18:41 UTC (History)
3 users (show)

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:

Description computerzerstoerer 2015-01-02 11:01:44 UTC
tl;dr When the LLVM backend is enabled, the entire runtime will crash whenever any exception is thrown.

Simple example code:

using System;

namespace LelVM
	public class MainClass
		public static void Main(string[] args)
			throw new NotImplementedException();

I compiled mono from the 3.10.0 tarball:

Mono JIT compiler version 3.10.0 (tarball Fr 2. Jan 15:52:35 CET 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          bigarrays softdebug 
	LLVM:          yes(3.6.0svn-mono-/)
	GC:            sgen

The symbol 'LelVM_MainClass_Meth' is visible because I AOT'd the assembly, but the issue occurs without that as well.
Output (with --trace):

[0x7f2dfe053800:] EXCEPTION handling: System.NotImplementedException: The requested feature is not implemented.
* Assertion at mini-exceptions.c:2771, condition `info' not met


Native stacktrace:

	/fancy/glacier/gregmono/bin/mono() [0x4bdbc4]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0xfc90) [0x7f2dfd001c90]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f2dfca4cd27]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7f2dfca4e418]
	/fancy/glacier/gregmono/bin/mono() [0x73a313]
	/fancy/glacier/gregmono/bin/mono() [0x73a222]
	/fancy/glacier/gregmono/bin/mono() [0x73a5dd]
	/fancy/glacier/gregmono/bin/mono() [0x4be3bb]
	/fancy/glacier/gregmono/bin/mono() [0x521f4a]
	/fancy/glacier/gregmono/bin/mono() [0x4baa08]
	/fancy/glacier/gregmono/bin/mono() [0x4bc4b2]
	/fancy/glacier/gregmono/bin/mono() [0x4bbf52]
	/fancy/glacier/gregmono/bin/mono() [0x5213d1]

Debug info from gdb:

  File "/fancy/glacier/gregmono/bin/mono-sgen-gdb.py", line 34
    c = "\u%X".format (val)
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \uXXXX escape
[New LWP 19130]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f2dfd001839 in __libc_waitpid (pid=19131, stat_loc=0x7fffc0363c3c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
40	../sysdeps/unix/sysv/linux/waitpid.c: Datei oder Verzeichnis nicht gefunden.
  Id   Target Id         Frame 
  2    Thread 0x7f2dfa11c700 (LWP 19130) "Finalizer" sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
* 1    Thread 0x7f2dfe053800 (LWP 19129) "mono" 0x00007f2dfd001839 in __libc_waitpid (pid=19131, stat_loc=0x7fffc0363c3c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40

Thread 2 (Thread 0x7f2dfa11c700 (LWP 19130)):
#0  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
#1  0x0000000000727c48 in mono_sem_wait (sem=0x18a4cf0 <finalizer_sem>, alertable=1) at mono-semaphore.c:101
#2  0x000000000062d9f7 in finalizer_thread (unused=0x0) at gc.c:1077
#3  0x00000000005f7f26 in start_wrapper_internal (data=0x2855ed0) at threads.c:660
#4  0x00000000005f7c41 in start_wrapper (data=0x2855ed0) at threads.c:707
#5  0x0000000000730da5 in inner_start_thread (arg=0x7fffc03654a0) at mono-threads-posix.c:84
#6  0x00007f2dfcffa0a5 in start_thread (arg=0x7f2dfa11c700) at pthread_create.c:309
#7  0x00007f2dfcb1077d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7f2dfe053800 (LWP 19129)):
#0  0x00007f2dfd001839 in __libc_waitpid (pid=19131, stat_loc=0x7fffc0363c3c, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
#1  0x00000000004bdc31 in mono_handle_native_sigsegv (signal=<optimized out>, ctx=<optimized out>) at mini-exceptions.c:2323
#2  <signal handler called>
#3  0x00007f2dfca4cd27 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#4  0x00007f2dfca4e418 in __GI_abort () at abort.c:89
#5  0x000000000073a313 in monoeg_log_default_handler (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, message=0x278a8b0 "* Assertion at mini-exceptions.c:2771, condition `info' not met\n", unused_data=0x0) at goutput.c:232
#6  0x000000000073a222 in monoeg_g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=0x1175565 "* Assertion at %s:%d, condition `%s' not met\n", args=0x7fffc0364de0) at goutput.c:113
#7  0x000000000073a5dd in monoeg_assertion_message (format=0x1175565 "* Assertion at %s:%d, condition `%s' not met\n") at goutput.c:133
#8  0x00000000004be3bb in mono_jinfo_get_epilog_size (ji=<optimized out>) at mini-exceptions.c:2771
#9  0x0000000000521f4a in mono_arch_find_jit_info (domain=<optimized out>, jit_tls=<optimized out>, ji=0x7f2dfe076050, ctx=<optimized out>, new_ctx=0x7fffc0365190, lmf=<optimized out>, save_locations=<optimized out>, frame=<optimized out>) at exceptions-amd64.c:607
#10 0x00000000004baa08 in mono_find_jit_info_ext (domain=0x27189f0, jit_tls=0x2786f60, prev_ji=<optimized out>, ctx=0x7fffc03650a8, new_ctx=0x7fffc0365190, trace=0x0, lmf=0x7fffc03652a0, save_locations=0x0, frame=<optimized out>) at mini-exceptions.c:376
#11 0x00000000004bc4b2 in mono_handle_exception_internal_first_pass (ctx=0x7f2dfb400c78, obj=<optimized out>, out_filter_idx=<Fehler beim Lesen der Variable: Cannot access memory at address 0x0>, out_ji=<optimized out>, non_exception=<optimized out>, out_prev_ji=<optimized out>) at mini-exceptions.c:1373
#12 mono_handle_exception_internal (ctx=<optimized out>, obj=<optimized out>, resume=0, out_ji=<optimized out>) at mini-exceptions.c:1638
#13 0x00000000004bbf52 in mono_handle_exception (ctx=0x4ab9, obj=0x4ab9) at mini-exceptions.c:1937
#14 0x00000000005213d1 in mono_amd64_throw_exception (dummy1=<optimized out>, dummy2=<optimized out>, dummy3=6, dummy4=18446744073709551615, dummy5=139835512010752, dummy6=4, regs=0x7fffc03653b0, rip=<optimized out>, exc=0x7f2dfb400c78, rethrow=0) at exceptions-amd64.c:375
#15 0x00000000407793a0 in ?? ()
#16 0x00007fffc03653b0 in ?? ()
#17 0x00007f2df9d1b473 in LelVM_MainClass_Meth () from /fancy/glacier/home/monodev/LelVM/LelVM/bin/Debug/LelVM.exe.so
#18 0x00007f2dfb400c78 in ?? ()
#19 0x0000000000000000 in ?? ()

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 2015-01-02 18:19:19 UTC
This is already fixed in mono 3.12/master.