Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM JIT on Linux x64 not working #12030

Closed
directhex opened this issue Dec 12, 2018 · 22 comments

Comments

@directhex
Copy link
Contributor

@directhex directhex commented Dec 12, 2018

LLVM AOT is OK, but LLVM JIT isn't.

This is with an out-of-tree build of LLVM, with git commit matching the in-tree builds.

$ mono --llvm hello.exe
LLVM JIT not supported on this platform.
Stacktrace:

/proc/self/maps:
40886000-40896000 rwxp 00000000 00:00 0 
41075000-41085000 rwxp 00000000 00:00 0 
55e88dd3b000-55e88e184000 r-xp 00000000 fd:01 12981678                   /usr/bin/mono-sgen
55e88e383000-55e88e38a000 r--p 00448000 fd:01 12981678                   /usr/bin/mono-sgen
55e88e38a000-55e88e38f000 rw-p 0044f000 fd:01 12981678                   /usr/bin/mono-sgen
55e88e38f000-55e88e420000 rw-p 00000000 00:00 0 
55e89005a000-55e890122000 rw-p 00000000 00:00 0                          [heap]
7f998a3c1000-7f998a97d000 r-xp 00000000 fd:01 14418350                   /usr/lib/mono/aot-cache/amd64/mscorlib.dll.so
7f998a97d000-7f998ab7c000 ---p 005bc000 fd:01 14418350                   /usr/lib/mono/aot-cache/amd64/mscorlib.dll.so
7f998ab7c000-7f998ab7d000 r--p 005bb000 fd:01 14418350                   /usr/lib/mono/aot-cache/amd64/mscorlib.dll.so
7f998ab7d000-7f998ab7e000 rw-p 005bc000 fd:01 14418350                   /usr/lib/mono/aot-cache/amd64/mscorlib.dll.so
7f998ab7e000-7f998aba8000 rw-p 00000000 00:00 0 
7f998aba8000-7f998afff000 r--p 00000000 fd:01 14156849                   /usr/lib/mono/4.5/mscorlib.dll
7f998afff000-7f998bfff000 rw-p 00000000 00:00 0 
7f998bfff000-7f998c000000 ---p 00000000 00:00 0 
7f998c000000-7f998cc00000 rw-p 00000000 00:00 0 
7f998cd7b000-7f998cef4000 r-xp 00000000 fd:01 12980533                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f998cef4000-7f998d0f4000 ---p 00179000 fd:01 12980533                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f998d0f4000-7f998d0fe000 r--p 00179000 fd:01 12980533                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f998d0fe000-7f998d100000 rw-p 00183000 fd:01 12980533                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f998d100000-7f998d104000 rw-p 00000000 00:00 0 
7f998d104000-7f998db1a000 r-xp 00000000 fd:01 12978617                   /usr/lib/libmono-llvm.so.0.0.0
7f998db1a000-7f998dd1a000 ---p 00a16000 fd:01 12978617                   /usr/lib/libmono-llvm.so.0.0.0
7f998dd1a000-7f998dd32000 r--p 00a16000 fd:01 12978617                   /usr/lib/libmono-llvm.so.0.0.0
7f998dd32000-7f998dd37000 rw-p 00a2e000 fd:01 12978617                   /usr/lib/libmono-llvm.so.0.0.0
Memory around native instruction pointer (0x7f998e05de97):
0x7f998e05de87  d2 4c 89 ce bf 02 00 00 00 b8 0e 00 00 00 0f 05  .L..............
0x7f998e05de97  48 8b 8c 24 08 01 00 00 64 48 33 0c 25 28 00 00  H..$....dH3.%(..
0x7f998e05dea7  00 44 89 c0 75 1f 48 81 c4 18 01 00 00 c3 0f 1f  .D..u.H.........
0x7f998e05deb7  00 48 8b 15 a9 bf 3a 00 f7 d8 41 b8 ff ff ff ff  .H....:...A.....

Native stacktrace:

	mono(+0x129f6d) [0x55e88de64f6d]
	mono(+0x12a275) [0x55e88de65275]
	mono(+0xbfcbf) [0x55e88ddfacbf]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890) [0x7f998e63a890]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7) [0x7f998e05de97]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x141) [0x7f998e05f801]
	/usr/lib/libmono-llvm.so(+0x13cc79) [0x7f998d240c79]
	/usr/lib/libmono-llvm.so(+0x13cb9b) [0x7f998d240b9b]
	/usr/lib/libmono-llvm.so(monoeg_g_logv+0x9) [0x7f998d240ee9]
	/usr/lib/libmono-llvm.so(monoeg_g_log+0x8f) [0x7f998d240f8f]
	/usr/lib/libmono-llvm.so(+0x139119) [0x7f998d23d119]
	/usr/lib/libmono-llvm.so(mono_llvm_emit_method+0x500) [0x7f998d239380]
	mono(+0x13056c) [0x55e88de6b56c]
	mono(+0x130f22) [0x55e88de6bf22]
	mono(+0x3f63a) [0x55e88dd7a63a]
	mono(+0x41012) [0x55e88dd7c012]
	mono(+0x21c170) [0x55e88df57170]
	mono(+0x21e7a6) [0x55e88df597a6]
	mono(+0x1cb178) [0x55e88df06178]
	mono(+0x1cb84e) [0x55e88df0684e]
	mono(+0x1988b6) [0x55e88ded38b6]
	mono(+0x19b2f8) [0x55e88ded62f8]
	mono(+0x43f2a) [0x55e88dd7ef2a]
	mono(mono_main+0x479) [0x55e88ddc66e9]
	mono(+0x3a2ac) [0x55e88dd752ac]
	/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f998e040b97]
	mono(_start+0x2a) [0x55e88dd75a1a]
Entering thread summarizer pause from 0x7f998f1df780
Finished thread summarizer pause from 0x7f998f1df780.

Waiting for dumping threads to resume


Debug info from gdb:

[New LWP 17298]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f998e63a23a in __waitpid (pid=pid@entry=17299, stat_loc=stat_loc@entry=0x7ffdfd65a1a4, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
30	../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
  Id   Target Id         Frame 
* 1    Thread 0x7f998f1df780 (LWP 17297) "mono" 0x00007f998e63a23a in __waitpid (pid=pid@entry=17299, stat_loc=stat_loc@entry=0x7ffdfd65a1a4, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
  2    Thread 0x7f998c7ff700 (LWP 17298) "SGen worker" 0x00007f998e6359f3 in futex_wait_cancelable (private=<optimised out>, expected=0, futex_word=0x55e88e3a3b48 <work_cond+40>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88

Thread 2 (Thread 0x7f998c7ff700 (LWP 17298)):
#0  0x00007f998e6359f3 in futex_wait_cancelable (private=<optimised out>, expected=0, futex_word=0x55e88e3a3b48 <work_cond+40>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x55e88e3a3b60 <lock>, cond=0x55e88e3a3b20 <work_cond>) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=cond@entry=0x55e88e3a3b20 <work_cond>, mutex=mutex@entry=0x55e88e3a3b60 <lock>) at pthread_cond_wait.c:655
#3  0x000055e88e02cbea in mono_os_cond_wait (mutex=0x55e88e3a3b60 <lock>, cond=0x55e88e3a3b20 <work_cond>) at ../../mono/utils/mono-os-mutex.h:173
#4  get_work (job=<synthetic pointer>, do_idle=<synthetic pointer>, work_context=<synthetic pointer>, worker_index=0) at sgen-thread-pool.c:165
#5  thread_func (data=<optimised out>) at sgen-thread-pool.c:196
#6  0x00007f998e62f6db in start_thread (arg=0x7f998c7ff700) at pthread_create.c:463
#7  0x00007f998e14088f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f998f1df780 (LWP 17297)):
#0  0x00007f998e63a23a in __waitpid (pid=pid@entry=17299, stat_loc=stat_loc@entry=0x7ffdfd65a1a4, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1  0x000055e88de650d3 in dump_native_stacktrace (ctx=ctx@entry=0x7ffdfd65adc0, signal=0x55e88e073a28 "SIGABRT") at mini-posix.c:1079
#2  0x000055e88de65275 in mono_dump_native_crash_info (signal=signal@entry=0x55e88e073a28 "SIGABRT", ctx=ctx@entry=0x7ffdfd65adc0, info=info@entry=0x7ffdfd65aef0) at mini-posix.c:1102
#3  0x000055e88ddfacbf in mono_handle_native_crash (signal=0x55e88e073a28 "SIGABRT", ctx=0x7ffdfd65adc0, info=0x7ffdfd65aef0) at mini-exceptions.c:3170
#4  <signal handler called>
#5  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#6  0x00007f998e05f801 in __GI_abort () at abort.c:79
#7  0x00007f998d240c79 in monoeg_log_default_handler () from /usr/lib/libmono-llvm.so
#8  0x00007f998d240b9b in ?? () from /usr/lib/libmono-llvm.so
#9  0x00007f998d240ee9 in monoeg_g_logv () from /usr/lib/libmono-llvm.so
#10 0x00007f998d240f8f in monoeg_g_log () from /usr/lib/libmono-llvm.so
#11 0x00007f998d23d119 in ?? () from /usr/lib/libmono-llvm.so
#12 0x00007f998d239380 in mono_llvm_emit_method () from /usr/lib/libmono-llvm.so
#13 0x000055e88de6b56c in mini_method_compile (method=method@entry=0x55e8900b4d00, opts=opts@entry=374434303, domain=domain@entry=0x55e890084dc0, flags=flags@entry=JIT_FLAG_RUN_CCTORS, parts=parts@entry=0, aot_method_index=aot_method_index@entry=-1) at mini.c:3827
#14 0x000055e88de6bf22 in mono_jit_compile_method_inner (method=method@entry=0x55e8900b4d00, target_domain=target_domain@entry=0x55e890084dc0, opt=opt@entry=374434303, error=error@entry=0x7ffdfd65bd80) at mini.c:4043
#15 0x000055e88dd7a63a in mono_jit_compile_method_with_opt (method=method@entry=0x55e8900b4d00, opt=374434303, jit_only=jit_only@entry=0, error=error@entry=0x7ffdfd65bd80) at mini-runtime.c:2411
#16 0x000055e88dd7b5ac in mono_jit_compile_method (method=method@entry=0x55e8900b4d00, error=error@entry=0x7ffdfd65bd80) at mini-runtime.c:2457
#17 0x000055e88dd7c012 in create_runtime_invoke_info (error=0x7ffdfd65bd80, use_interp=<optimised out>, callee_gsharedvt=<optimised out>, compiled_method=<optimised out>, method=0x55e8900b4828, domain=0x55e890084dc0) at mini-runtime.c:2847
#18 mono_jit_runtime_invoke (method=0x55e8900b4828, obj=<optimised out>, params=0x7ffdfd65bc90, exc=0x0, error=0x7ffdfd65bd80) at mini-runtime.c:3034
#19 0x000055e88df57170 in do_runtime_invoke (method=0x55e8900b4828, obj=<optimised out>, params=<optimised out>, exc=<optimised out>, error=0x7ffdfd65bd80) at object.c:2960
#20 0x000055e88df597a6 in mono_runtime_invoke_handle (method=method@entry=0x55e8900b4828, obj=..., obj@entry=..., params=params@entry=0x7ffdfd65bc90, error=error@entry=0x7ffdfd65bd80) at object.c:3134
#21 0x000055e88df06178 in create_exception_two_strings (klass=klass@entry=0x55e8900b4020, a1=a1@entry=..., a2=..., a2@entry=..., error=error@entry=0x7ffdfd65bd80) at exception.c:205
#22 0x000055e88df0684e in mono_exception_from_name_two_strings_checked (image=<optimised out>, name_space=name_space@entry=0x55e88e088663 "System", name=name@entry=0x55e88e06a7db "OutOfMemoryException", a1=..., a2=a2@entry=..., error=error@entry=0x7ffdfd65bd80) at exception.c:265
#23 0x000055e88ded38b6 in create_domain_objects (domain=domain@entry=0x55e890084dc0) at appdomain.c:217
#24 0x000055e88ded62f8 in mono_runtime_init_checked (domain=domain@entry=0x55e890084dc0, start_cb=start_cb@entry=0x55e88dd76a80 <mono_thread_start_cb>, attach_cb=attach_cb@entry=0x55e88dd76a30 <mono_thread_attach_cb>, error=error@entry=0x7ffdfd65bf70) at appdomain.c:316
#25 0x000055e88dd7ef2a in mini_init (filename=<optimised out>, runtime_version=runtime_version@entry=0x0) at mini-runtime.c:4480
#26 0x000055e88ddc66e9 in mono_main (argc=<optimised out>, argv=<optimised out>) at driver.c:2316
#27 0x000055e88dd752ac in mono_main_with_options (argv=<optimised out>, argc=<optimised out>) at main.c:50
#28 main (argc=<optimised out>, argv=<optimised out>) at main.c:405

=================================================================
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.
=================================================================

Aborted (core dumped)

@pr0vieh

This comment has been minimized.

Copy link

@pr0vieh pr0vieh commented Dec 12, 2018

Same as #10868 but with more info

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Dec 13, 2018

This time with -O0 and symbols in libmono-llvm.so:

LLVM JIT not supported on this platform.
Stacktrace:

/proc/self/maps:
404b9000-404c9000 rwxp 00000000 00:00 0 
40ea9000-40eb9000 rwxp 00000000 00:00 0 
5576e6878000-5576e6efb000 r-xp 00000000 fd:01 4966183                    /tmp/monoparty/bin/mono-sgen
5576e70fa000-5576e7100000 r--p 00682000 fd:01 4966183                    /tmp/monoparty/bin/mono-sgen
5576e7100000-5576e7106000 rw-p 00688000 fd:01 4966183                    /tmp/monoparty/bin/mono-sgen
5576e7106000-5576e7197000 rw-p 00000000 00:00 0 
5576e8e73000-5576e8f19000 rw-p 00000000 00:00 0                          [heap]
7f281efa8000-7f281f3ff000 r--p 00000000 fd:01 4968299                    /tmp/monoparty/lib/mono/4.5/mscorlib.dll
7f281f3ff000-7f28203ff000 rw-p 00000000 00:00 0 
7f28203ff000-7f2820400000 ---p 00000000 00:00 0 
7f2820400000-7f2821000000 rw-p 00000000 00:00 0 
7f282116d000-7f28212e6000 r-xp 00000000 fd:01 12980533                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f28212e6000-7f28214e6000 ---p 00179000 fd:01 12980533                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f28214e6000-7f28214f0000 r--p 00179000 fd:01 12980533                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f28214f0000-7f28214f2000 rw-p 00183000 fd:01 12980533                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
7f28214f2000-7f28214f6000 rw-p 00000000 00:00 0 
7f28214f6000-7f2821f4a000 r-xp 00000000 fd:01 4966179                    /tmp/monoparty/lib/libmono-llvm.so.0.0.0
7f2821f4a000-7f282214a000 ---p 00a54000 fd:01 4966179                    /tmp/monoparty/lib/libmono-llvm.so.0.0.0
7f282214a000-7f2822162000 r--p 00a54000 fd:01 4966179                    /tmp/monoparty/lib/libmono-llvm.so.0.0.0
7f2822162000-7f2822170000 rw-p 00a6c000 fd:01 4966179                    /tmp/monoparty/lib/libmono-llvm.so.0.0.0
7f2822170000-7f282217a000 rw-p 00000000 00:00 0 
7f282217a000-7f2822458000 r--p 00000000 fd:01 12977619                   /usr/lib/locale/locale-archive
7f2822458000-7f282263f000 r-xp 00000000 fd:01 10360733                   /lib/x86_64-linux-gnu/libc-2.27.so
7f282263f000-7f282283f000 ---p 001e7000 fd:01 10360733                   /lib/x86_64-linux-gnu/libc-2.27.so
7f282283f000-7f2822843000 r--p 001e7000 fd:01 10360733                   /lib/x86_64-linux-gnu/libc-2.27.so
Memory around native instruction pointer (0x7f2822496e97):
0x7f2822496e87  d2 4c 89 ce bf 02 00 00 00 b8 0e 00 00 00 0f 05  .L..............
0x7f2822496e97  48 8b 8c 24 08 01 00 00 64 48 33 0c 25 28 00 00  H..$....dH3.%(..
0x7f2822496ea7  00 44 89 c0 75 1f 48 81 c4 18 01 00 00 c3 0f 1f  .D..u.H.........
0x7f2822496eb7  00 48 8b 15 a9 bf 3a 00 f7 d8 41 b8 ff ff ff ff  .H....:...A.....

Native stacktrace:

	/tmp/monoparty/bin/mono-sgen(+0x1fd09b) [0x5576e6a7509b]
	/tmp/monoparty/bin/mono-sgen(+0x1fd359) [0x5576e6a75359]
	/tmp/monoparty/bin/mono-sgen(+0x1231d7) [0x5576e699b1d7]
	/tmp/monoparty/bin/mono-sgen(+0x1fb9de) [0x5576e6a739de]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890) [0x7f2822a73890]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7) [0x7f2822496e97]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x141) [0x7f2822498801]
	/tmp/monoparty/bin/mono-sgen(+0x4e8481) [0x5576e6d60481]
	/tmp/monoparty/bin/mono-sgen(+0x4df2ce) [0x5576e6d572ce]
	/tmp/monoparty/bin/mono-sgen(+0x50a8eb) [0x5576e6d828eb]
	/tmp/monoparty/bin/mono-sgen(+0x50a94b) [0x5576e6d8294b]
	/tmp/monoparty/bin/mono-sgen(monoeg_g_logv+0x2e) [0x5576e6d82993]
	/tmp/monoparty/bin/mono-sgen(monoeg_g_log+0xba) [0x5576e6d82a58]
	/tmp/monoparty/lib/libmono-llvm.so.0(+0x170729) [0x7f2821666729]
	/tmp/monoparty/lib/libmono-llvm.so.0(+0x16c15f) [0x7f282166215f]
	/tmp/monoparty/lib/libmono-llvm.so.0(mono_llvm_emit_method+0x2ec) [0x7f282165d6d5]
	/tmp/monoparty/bin/mono-sgen(mono_llvm_emit_method+0x1c) [0x5576e69ffee2]
	/tmp/monoparty/bin/mono-sgen(+0x20983e) [0x5576e6a8183e]
	/tmp/monoparty/bin/mono-sgen(+0x20a39c) [0x5576e6a8239c]
	/tmp/monoparty/bin/mono-sgen(+0x33b34) [0x5576e68abb34]
	/tmp/monoparty/bin/mono-sgen(+0x33d81) [0x5576e68abd81]
	/tmp/monoparty/bin/mono-sgen(+0x355f0) [0x5576e68ad5f0]
	/tmp/monoparty/bin/mono-sgen(+0x368b5a) [0x5576e6be0b5a]
	/tmp/monoparty/bin/mono-sgen(+0x368f08) [0x5576e6be0f08]
	/tmp/monoparty/bin/mono-sgen(+0x368f72) [0x5576e6be0f72]
	/tmp/monoparty/bin/mono-sgen(+0x2e9c4b) [0x5576e6b61c4b]
	/tmp/monoparty/bin/mono-sgen(+0x2e9f58) [0x5576e6b61f58]
	/tmp/monoparty/bin/mono-sgen(+0x29f0ba) [0x5576e6b170ba]
	/tmp/monoparty/bin/mono-sgen(+0x29f8cb) [0x5576e6b178cb]
	/tmp/monoparty/bin/mono-sgen(+0x38cc4) [0x5576e68b0cc4]
	/tmp/monoparty/bin/mono-sgen(mono_main+0x21bd) [0x5576e695277c]
	/tmp/monoparty/bin/mono-sgen(+0x2ce56) [0x5576e68a4e56]
	/tmp/monoparty/bin/mono-sgen(+0x2dc31) [0x5576e68a5c31]
	/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f2822479b97]
	/tmp/monoparty/bin/mono-sgen(_start+0x2a) [0x5576e68a4d0a]
Entering thread summarizer pause from 0x7f2823618780
Finished thread summarizer pause from 0x7f2823618780.

Waiting for dumping threads to resume


Debug info from gdb:

[New LWP 14351]
warning: File "/tmp/monoparty/bin/mono-sgen-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file, add
	add-auto-load-safe-path /tmp/monoparty/bin/mono-sgen-gdb.py
line to your configuration file "/home/directhex/.gdbinit".
To completely disable this security protection, add
	set auto-load safe-path /
line to your configuration file "/home/directhex/.gdbinit".
For more information about this security protection, see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f2822a7323a in __waitpid (pid=14352, stat_loc=0x7ffc2f7c4f64, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
30	../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
  Id   Target Id         Frame 
* 1    Thread 0x7f2823618780 (LWP 14350) "mono-sgen" 0x00007f2822a7323a in __waitpid (pid=14352, stat_loc=0x7ffc2f7c4f64, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
  2    Thread 0x7f2820bff700 (LWP 14351) "SGen worker" 0x00007f2822a6e9f3 in futex_wait_cancelable (private=<optimised out>, expected=0, futex_word=0x5576e711aae8 <work_cond+40>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88

Thread 2 (Thread 0x7f2820bff700 (LWP 14351)):
#0  0x00007f2822a6e9f3 in futex_wait_cancelable (private=<optimised out>, expected=0, futex_word=0x5576e711aae8 <work_cond+40>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x5576e711aa80 <lock>, cond=0x5576e711aac0 <work_cond>) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x5576e711aac0 <work_cond>, mutex=0x5576e711aa80 <lock>) at pthread_cond_wait.c:655
#3  0x00005576e6d4f6c9 in mono_os_cond_wait (cond=0x5576e711aac0 <work_cond>, mutex=0x5576e711aa80 <lock>) at ../../mono/utils/mono-os-mutex.h:173
#4  0x00005576e6d50655 in get_work (worker_index=0, work_context=0x7f2820bfee84, do_idle=0x7f2820bfee88, job=0x7f2820bfee90) at sgen-thread-pool.c:165
#5  0x00005576e6d507f9 in thread_func (data=0x0) at sgen-thread-pool.c:196
#6  0x00007f2822a686db in start_thread (arg=0x7f2820bff700) at pthread_create.c:463
#7  0x00007f282257988f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f2823618780 (LWP 14350)):
#0  0x00007f2822a7323a in __waitpid (pid=14352, stat_loc=0x7ffc2f7c4f64, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1  0x00005576e6a7530a in dump_native_stacktrace (signal=0x5576e6daec91 "SIGABRT", ctx=0x7ffc2f7c5ac0) at mini-posix.c:1079
#2  0x00005576e6a75359 in mono_dump_native_crash_info (signal=0x5576e6daec91 "SIGABRT", ctx=0x7ffc2f7c5ac0, info=0x7ffc2f7c5bf0) at mini-posix.c:1102
#3  0x00005576e699b1d7 in mono_handle_native_crash (signal=0x5576e6daec91 "SIGABRT", ctx=0x7ffc2f7c5ac0, info=0x7ffc2f7c5bf0) at mini-exceptions.c:3197
#4  0x00005576e6a739de in sigabrt_signal_handler (_dummy=6, _info=0x7ffc2f7c5bf0, context=0x7ffc2f7c5ac0) at mini-posix.c:223
#5  <signal handler called>
#6  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#7  0x00007f2822498801 in __GI_abort () at abort.c:79
#8  0x00005576e6d60481 in mono_log_write_logfile (log_domain=0x0, level=G_LOG_LEVEL_ERROR, hdr=0, message=0x5576e8efcd70 "LLVM JIT not supported on this platform.") at mono-log-common.c:135
#9  0x00005576e6d572ce in structured_log_adapter (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, message=0x5576e8efcd70 "LLVM JIT not supported on this platform.", user_data=0x0) at mono-logger.c:466
#10 0x00005576e6d828eb in monoeg_g_logstr (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, msg=0x5576e8efcd70 "LLVM JIT not supported on this platform.") at goutput.c:117
#11 0x00005576e6d8294b in monoeg_g_logv_nofree (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=0x7f2821b772f8 "LLVM JIT not supported on this platform.", args=0x7ffc2f7c6470) at goutput.c:128
#12 0x00005576e6d82993 in monoeg_g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=0x7f2821b772f8 "LLVM JIT not supported on this platform.", args=0x7ffc2f7c6470) at goutput.c:135
#13 0x00005576e6d82a58 in monoeg_g_log (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=0x7f2821b772f8 "LLVM JIT not supported on this platform.") at goutput.c:144
#14 0x00007f2821666729 in mono_llvm_create_ee (MP=<optimised out>, alloc_cb=<optimised out>, emitted_cb=<optimised out>, exception_cb=<optimised out>, dlsym_cb=<optimised out>, ee=<optimised out>) at llvm-jit.cpp:877
#15 0x00007f282166215f in init_jit_module (domain=0x5576e8e9ddd0) at mini-llvm.c:8525
#16 0x00007f282165d6d5 in mono_llvm_emit_method (cfg=0x5576e8eff4b0) at mini-llvm.c:6990
#17 0x00005576e69ffee2 in mono_llvm_emit_method (cfg=0x5576e8eff4b0) at mini-llvm-loaded.c:43
#18 0x00005576e6a8183e in mini_method_compile (method=0x5576e8efd6d0, opts=374434303, domain=0x5576e8e9ddd0, flags=JIT_FLAG_RUN_CCTORS, parts=0, aot_method_index=-1) at mini.c:3827
#19 0x00005576e6a8239c in mono_jit_compile_method_inner (method=0x5576e8efd6d0, target_domain=0x5576e8e9ddd0, opt=374434303, error=0x7ffc2f7c7040) at mini.c:4043
#20 0x00005576e68abb34 in mono_jit_compile_method_with_opt (method=0x5576e8efd6d0, opt=374434303, jit_only=1, error=0x7ffc2f7c7040) at mini-runtime.c:2411
#21 0x00005576e68abd81 in mono_jit_compile_method_jit_only (method=0x5576e8efd6d0, error=0x7ffc2f7c7040) at mini-runtime.c:2471
#22 0x00005576e68ad5f0 in mono_jit_runtime_invoke (method=0x5576e8efd6d0, obj=0x7f2820c00048, params=0x7ffc2f7c6ed0, exc=0x0, error=0x7ffc2f7c7040) at mini-runtime.c:3011
#23 0x00005576e6be0b5a in do_runtime_invoke (method=0x5576e8efd6d0, obj=0x7f2820c00048, params=0x7ffc2f7c6ed0, exc=0x0, error=0x7ffc2f7c7040) at object.c:2960
#24 0x00005576e6be0f08 in mono_runtime_invoke_checked (method=0x5576e8efd6d0, obj=0x7f2820c00048, params=0x7ffc2f7c6ed0, error=0x7ffc2f7c7040) at object.c:3128
#25 0x00005576e6be0f72 in mono_runtime_invoke_handle (method=0x5576e8efd6d0, obj=..., params=0x7ffc2f7c6ed0, error=0x7ffc2f7c7040) at object.c:3134
#26 0x00005576e6b61c4b in create_exception_two_strings (klass=0x5576e8ef82a8, a1=..., a2=..., error=0x7ffc2f7c7040) at exception.c:205
#27 0x00005576e6b61f58 in mono_exception_from_name_two_strings_checked (image=0x5576e8ea2770, name_space=0x5576e6dc15fb "System", name=0x5576e6dc16ac "OutOfMemoryException", a1=..., a2=..., error=0x7ffc2f7c7040) at exception.c:265
#28 0x00005576e6b170ba in create_domain_objects (domain=0x5576e8e9ddd0) at appdomain.c:217
#29 0x00005576e6b178cb in mono_runtime_init_checked (domain=0x5576e8e9ddd0, start_cb=0x5576e68a8172 <mono_thread_start_cb>, attach_cb=0x5576e68a81fd <mono_thread_attach_cb>, error=0x7ffc2f7c7280) at appdomain.c:316
#30 0x00005576e68b0cc4 in mini_init (filename=0x7ffc2f7c814e "/tmp/hello.exe", runtime_version=0x0) at mini-runtime.c:4480
#31 0x00005576e695277c in mono_main (argc=3, argv=0x7ffc2f7c75c8) at driver.c:2316
#32 0x00005576e68a4e56 in mono_main_with_options (argc=3, argv=0x7ffc2f7c75c8) at main.c:50
#33 0x00005576e68a5c31 in main (argc=3, argv=0x7ffc2f7c75c8) at main.c:405

=================================================================
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.
=================================================================

Aborted (core dumped)
@migueldeicaza

This comment has been minimized.

Copy link
Member

@migueldeicaza migueldeicaza commented Dec 20, 2018

Ok the exception shows why:

/* These can't go into mini-<ARCH>.h since thats not included into llvm-jit.cpp */
#if defined(TARGET_AMD64) && defined(TARGET_OSX)
#define MONO_ARCH_LLVM_JIT_SUPPORTED 1
#elif defined(TARGET_X86) && defined(TARGET_OSX)
#define MONO_ARCH_LLVM_JIT_SUPPORTED 1
#endif

We explicitly only support LLVM JIT on OSX.

@pr0vieh

This comment has been minimized.

Copy link

@pr0vieh pr0vieh commented Dec 24, 2018

is this wanted or a mistake?
and will someday be supported?

@turbo

This comment has been minimized.

Copy link
Contributor

@turbo turbo commented Jan 2, 2019

@migueldeicaza ^ any comments?

@lewurm

This comment has been minimized.

Copy link
Member

@lewurm lewurm commented Jan 2, 2019

No one has tried it yet. Chances are good that it just works. Feel free to try it, test it and submit a PR 🙂 or report issues here otherwise.

monojenkins added a commit that referenced this issue Jan 16, 2019
[mini] re-enable LLVM for Linux JIT

This re-enables the Linux JIT as suggested in #12030
@migueldeicaza

This comment has been minimized.

Copy link
Member

@migueldeicaza migueldeicaza commented Jan 17, 2019

@directhex Can we get updated packages with the above change?

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Jan 18, 2019

Sorry, not ignoring this, just have been 100% consumed with the Debian/Ubuntu upload. That should be wrapping up, so I can look to this today or Monday.

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Jan 18, 2019

@migueldeicaza I think there's an issue with loadedllvm mode (which the packages use, to make LLVM optional).

libmono-llvm.so needs a few symbols from the runtime:

root@breakfast:/tmp# objdump --dynamic-syms /usr/lib/libmono-llvm.so | grep patch
0000000000000000      D  *UND*	0000000000000000              mono_patch_info_equal
0000000000000000      D  *UND*	0000000000000000              mono_aot_patch_info_dup
0000000000000000      D  *UND*	0000000000000000              mono_patch_info_hash
0000000000000000      D  *UND*	0000000000000000              mono_add_patch_info
0000000000000000      D  *UND*	0000000000000000              mono_resolve_patch_target

You can see mono_patch_info_equal consumed here: https://github.com/mono/mono/blob/master/mono/mini/mini-llvm.c#L9065

However, that symbol isn't exported, so can't be found by the LLVM JIT:

root@breakfast:/tmp# objdump --dynamic-syms /usr/bin/mono-sgen | grep patch
0000000000130510 g    DF .text	0000000000000046  Base        mono_add_patch_info
000000000003d360 g    DF .text	0000000000000a53  Base        mono_resolve_patch_target
0000000000130560 g    DF .text	0000000000000049  Base        mono_add_patch_info_rel
000000000009dbe0 g    DF .text	00000000000000bb  Base        mono_aot_patch_info_dup

End result:

root@breakfast:/tmp# mono --llvm hello.exe 
llvm load failed: /usr/lib/libmono-llvm.so: undefined symbol: mono_patch_info_equal

Mono Warning: llvm support could not be loaded.
@alexanderkyte

This comment has been minimized.

Copy link
Member

@alexanderkyte alexanderkyte commented Mar 18, 2019

Starting on this now. My linux desktop is building everything.

@alexanderkyte

This comment has been minimized.

Copy link
Member

@alexanderkyte alexanderkyte commented Mar 18, 2019

I am not seeing this on x64 ubuntu 16.04 with in-tree LLVM:

akyte@scw-0aff1b ~/mono_llvm_jit/mcs/class/corlib (master*) $ MONO_EXECUTABLE="lldb /home/akyte/mono_llvm_jit/mono/mini/mono-sgen -- " PATH="/home/akyte/mono_llvm_jit/runtime/_tmpinst/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/akyte/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/home/akyte/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/home/akyte/.antigen/bundles/zsh-users/zsh-syntax-highlighting" MONO_REGISTRY_PATH="/home/akyte/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" DBG_RUNTIME_ARGS="" MONO_PATH="./../../class/lib/net_4_x-linux:./../../class/lib/net_4_x-linux/tests:.:./../../../external/xunit-binaries:$MONO_PATH" /home/akyte/mono_llvm_jit/runtime/mono-wrapper --debug --llvm  ./../../class/lib/net_4_x-linux/nunit-lite-console.exe  ./../../class/lib/net_4_x/tests/net_4_x_corlib_test.dll    -exclude=NotWorking,CAS
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/lldb/__init__.py", line 123, in <module>
    import six
ImportError: No module named six
(lldb) target create "/home/akyte/mono_llvm_jit/mono/mini/mono-sgen"
Current executable set to '/home/akyte/mono_llvm_jit/mono/mini/mono-sgen' (x86_64).
(lldb) settings set -- target.run-args  "--config" "/home/akyte/mono_llvm_jit/runtime/etc/mono/config" "--debug" "--llvm" "./../../class/lib/net_4_x-linux/nunit-lite-console.exe" "./../../class/lib/net_4_x/tests/net_4_x_corlib_test.dll" "-exclude=NotWorking,CAS"
(lldb) b mono_llvm_init
Breakpoint 1: where = mono-sgen`mono_llvm_init + 4 at mini-llvm-loaded.c:32, address = 0x0000000000585c24
(lldb) c
error: invalid process
(lldb) r
Process 5480 launched: '/home/akyte/mono_llvm_jit/mono/mini/mono-sgen' (x86_64)
1 location added to breakpoint 1
Process 5480 stopped
* thread #1: tid = 5480, 0x0000000000585c24 mono-sgen`mono_llvm_init + 4 at mini-llvm-loaded.c:32, name = 'mono-sgen', stop reason = breakpoint 1.1
    frame #0: 0x0000000000585c24 mono-sgen`mono_llvm_init + 4 at mini-llvm-loaded.c:32
   29   void
   30   mono_llvm_init (void)
   31   {
-> 32           backend.init ();
   33   }
   34  
   35   void
(lldb) bt
* thread #1: tid = 5480, 0x0000000000585c24 mono-sgen`mono_llvm_init + 4 at mini-llvm-loaded.c:32, name = 'mono-sgen', stop reason = breakpoint 1.1
  * frame #0: 0x0000000000585c24 mono-sgen`mono_llvm_init + 4 at mini-llvm-loaded.c:32
    frame #1: 0x00000000004226e4 mono-sgen`mini_init(filename="./../../class/lib/net_4_x-linux/nunit-lite-console.exe", runtime_version=0x0000000000000000) + 1300 at mini-runtime.c:4286
    frame #2: 0x00000000004bc327 mono-sgen`mono_main(argc=8, argv=0x00007fffffffe228) + 8279 at driver.c:2502
    frame #3: 0x000000000041ba0e mono-sgen`mono_main_with_options(argc=8, argv=0x00007fffffffe228) + 46 at main.c:50
    frame #4: 0x000000000041b06c mono-sgen`main(argc=8, argv=0x00007fffffffe228) + 76 at main.c:408
    frame #5: 0x00007ffff6b63830 libc.so.6`__libc_start_main + 240
    frame #6: 0x000000000041aec9 mono-sgen`_start + 41
(lldb) c
Process 5480 resuming
Process 5480 stopped
* thread #1: tid = 5480, 0x00007ffff54d66c3 libmono-llvm.so`mono_llvm_init + 19 at mini-llvm.c:8901, name = 'mono-sgen', stop reason = breakpoint 1.2
    frame #0: 0x00007ffff54d66c3 libmono-llvm.so`mono_llvm_init + 19 at mini-llvm.c:8901
   8898         GHashTable *h;
   8899         int i;
   8900
-> 8901         mono_native_tls_alloc (&current_cfg_tls_id, NULL);
   8902
   8903         h = g_hash_table_new (NULL, NULL);
   8904         for (i = 0; i < INTRINS_NUM; ++i)
(lldb) br del 1
1 breakpoints deleted; 0 breakpoint locations disabled.
(lldb) 
(lldb) c
Process 5480 resuming
NUnitLite 1.0.0 (.NET 4.5 Debug)
Copyright 2013, Charlie Poole

Runtime Environment -
    OS Version: Unix 4.4.127.1
  Mono Version: 4.0.30319.42000

...............................
@brianrob

This comment has been minimized.

Copy link

@brianrob brianrob commented Mar 21, 2019

@alexanderkyte, any update on this? Thanks.

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Mar 22, 2019

OK, so, with Mono nightly (4111910) built against the out-of-tree branch tip of release_60 mono/llvm (286f43185878a77fdc78c3303db68e514969bc30) I get:

root@breakfast:/# mono --llvm /tmp/hello.exe 
mono: llvm-jit.cpp:297: void* mono_llvm_create_ee(LLVMModuleProviderRef, unsigned char* (*)(LLVMValueRef, int), void (*)(LLVMValueRef, void*, void*), void (*)(void*), char* (*)(const char*, void**), LLVMOpaqueExecutionEngine**): Assertion `TM' failed.

=================================================================
	Native Crash Reporting
=================================================================
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.
=================================================================
/proc/self/maps:
4123d000-4124d000 rwxp 00000000 00:00 0 
416fc000-4170c000 rwxp 00000000 00:00 0 
562c0984b000-562c09cd1000 r-xp 00000000 00:2f 12563                      /usr/bin/mono-sgen
562c09ed1000-562c09ed8000 r--p 00486000 00:2f 12563                      /usr/bin/mono-sgen
562c09ed8000-562c09edd000 rw-p 0048d000 00:2f 12563                      /usr/bin/mono-sgen
562c09edd000-562c09ef4000 rw-p 00000000 00:00 0 
562c0bade000-562c0bb83000 rw-p 00000000 00:00 0                          [heap]
7fad0279a000-7fad02bff000 r--p 00000000 00:2f 12589                      /usr/lib/mono/4.5/mscorlib.dll
7fad02bff000-7fad03bff000 rw-p 00000000 00:00 0 
7fad03bff000-7fad03c00000 ---p 00000000 00:00 0 
7fad03c00000-7fad04800000 rw-p 00000000 00:00 0 
7fad04bec000-7fad06002000 r-xp 00000000 00:2f 12625                      /usr/lib/libmono-llvm.so.0.0.0
7fad06002000-7fad06202000 ---p 01416000 00:2f 12625                      /usr/lib/libmono-llvm.so.0.0.0
7fad06202000-7fad06228000 r--p 01416000 00:2f 12625                      /usr/lib/libmono-llvm.so.0.0.0
7fad06228000-7fad0622f000 rw-p 0143c000 00:2f 12625                      /usr/lib/libmono-llvm.so.0.0.0
7fad0622f000-7fad0624a000 rw-p 00000000 00:00 0 
7fad0624a000-7fad06431000 r-xp 00000000 00:2f 484                        /lib/x86_64-linux-gnu/libc-2.27.so
7fad06431000-7fad06631000 ---p 001e7000 00:2f 484                        /lib/x86_64-linux-gnu/libc-2.27.so
7fad06631000-7fad06635000 r--p 001e7000 00:2f 484                        /lib/x86_64-linux-gnu/libc-2.27.so
7fad06635000-7fad06637000 rw-p 001eb000 00:2f 484                        /lib/x86_64-linux-gnu/libc-2.27.so
7fad06637000-7fad0663b000 rw-p 00000000 00:00 0 
7fad0663b000-7fad06652000 r-xp 00000000 00:2f 403                        /lib/x86_64-linux-gnu/libgcc_s.so.1
7fad06652000-7fad06851000 ---p 00017000 00:2f 403                        /lib/x86_64-linux-gnu/libgcc_s.so.1
7fad06851000-7fad06852000 r--p 00016000 00:2f 403                        /lib/x86_64-linux-gnu/libgcc_s.so.1
7fad06852000-7fad06853000 rw-p 00017000 00:2f 403                        /lib/x86_64-linux-gnu/libgcc_s.so.1

=================================================================
	Native stacktrace:
=================================================================
	0x562c0997cdc8 - mono : (null)
	0x562c0997d121 - mono : (null)
	0x562c0990a784 - mono : (null)
	0x7fad06f8c890 - /lib/x86_64-linux-gnu/libpthread.so.0 : (null)
	0x7fad06288e97 - /lib/x86_64-linux-gnu/libc.so.6 : gsignal
	0x7fad0628a801 - /lib/x86_64-linux-gnu/libc.so.6 : abort
	0x7fad0627a39a - /lib/x86_64-linux-gnu/libc.so.6 : (null)
	0x7fad0627a412 - /lib/x86_64-linux-gnu/libc.so.6 : (null)
	0x7fad04e0494d - /usr/lib/libmono-llvm.so : (null)
	0x7fad04dffe60 - /usr/lib/libmono-llvm.so : mono_llvm_emit_method
	0x562c09982e30 - mono : (null)
	0x562c09983b82 - mono : (null)
	0x562c0988b265 - mono : (null)
	0x562c0988cf2d - mono : (null)
	0x562c09a8e230 - mono : (null)
	0x562c09a90aad - mono : (null)
	0x562c09a240a8 - mono : (null)
	0x562c09a24745 - mono : (null)
	0x562c099effad - mono : (null)
	0x562c099f26b8 - mono : (null)
	0x562c09890c64 - mono : (null)
	0x562c098d59d1 - mono : mono_main
	0x562c09887bdc - mono : (null)
	0x7fad0626bb97 - /lib/x86_64-linux-gnu/libc.so.6 : __libc_start_main
	0x562c0988834a - mono : _start

=================================================================
	Telemetry Dumper:
=================================================================
Entering thread summarizer pause from 0x7fad077c1780
Finished thread summarizer pause from 0x7fad077c1780.

Waiting for dumping threads to resume

=================================================================
	External Debugger Dump:
=================================================================
[New LWP 10501]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007fad06f8c23a in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
  Id   Target Id         Frame 
* 1    Thread 0x7fad077c1780 (LWP 10500) "mono" 0x00007fad06f8c23a in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
  2    Thread 0x7fad043ff700 (LWP 10501) "SGen worker" 0x00007fad06f879f3 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0

Thread 2 (Thread 0x7fad043ff700 (LWP 10501)):
#0  0x00007fad06f879f3 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x0000562c09b6457a in mono_os_cond_wait (mutex=0x562c09ef1880 <lock>, cond=0x562c09ef1840 <work_cond>) at ../../mono/utils/mono-os-mutex.h:177
#2  get_work (job=<synthetic pointer>, do_idle=<synthetic pointer>, work_context=<synthetic pointer>, worker_index=0) at sgen-thread-pool.c:165
#3  thread_func (data=<optimized out>) at sgen-thread-pool.c:196
#4  0x00007fad06f816db in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#5  0x00007fad0636b88f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 1 (Thread 0x7fad077c1780 (LWP 10500)):
#0  0x00007fad06f8c23a in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x0000562c0997cff8 in dump_native_stacktrace (ctx=ctx@entry=0x7ffd501462c0, signal=0x562c09bae888 "SIGABRT") at mini-posix.c:1115
#2  0x0000562c0997d121 in mono_dump_native_crash_info (signal=signal@entry=0x562c09bae888 "SIGABRT", ctx=ctx@entry=0x7ffd501462c0, info=info@entry=0x7ffd501463f0) at mini-posix.c:1157
#3  0x0000562c0990a784 in mono_handle_native_crash (signal=0x562c09bae888 "SIGABRT", ctx=0x7ffd501462c0, info=0x7ffd501463f0) at mini-exceptions.c:3336
#4  <signal handler called>
#5  0x00007fad06288e97 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x00007fad0628a801 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#7  0x00007fad0627a39a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x00007fad0627a412 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#9  0x00007fad04e0494d in mono_llvm_create_ee (MP=<optimized out>, alloc_cb=alloc_cb@entry=0x7fad04dee7c0 <alloc_cb>, emitted_cb=emitted_cb@entry=0x7fad04dee770 <emitted_cb>, exception_cb=exception_cb@entry=0x7fad04ded710 <exception_cb>, dlsym_cb=dlsym_cb@entry=0x7fad04dee6c0 <dlsym_cb>, ee=ee@entry=0x562c0bb6f4a8) at llvm-jit.cpp:297
#10 0x00007fad04dffe60 in init_jit_module (domain=0x562c0bb0ca60) at mini-llvm.c:9023
#11 mono_llvm_emit_method (cfg=0x562c0bb63e80) at mini-llvm.c:7432
#12 0x0000562c09982e30 in mini_method_compile (method=method@entry=0x562c0bb61e50, opts=opts@entry=374434303, domain=domain@entry=0x562c0bb0ca60, flags=flags@entry=JIT_FLAG_RUN_CCTORS, parts=parts@entry=0, aot_method_index=aot_method_index@entry=-1) at mini.c:3805
#13 0x0000562c09983b82 in mono_jit_compile_method_inner (method=method@entry=0x562c0bb61e50, target_domain=target_domain@entry=0x562c0bb0ca60, opt=opt@entry=374434303, error=error@entry=0x7ffd50147540) at mini.c:4019
#14 0x0000562c0988b265 in mono_jit_compile_method_with_opt (method=method@entry=0x562c0bb61e50, opt=374434303, jit_only=jit_only@entry=1, error=error@entry=0x7ffd50147540) at mini-runtime.c:2479
#15 0x0000562c0988c1df in mono_jit_compile_method_jit_only (method=method@entry=0x562c0bb61e50, error=error@entry=0x7ffd50147540) at mini-runtime.c:2542
#16 0x0000562c0988cf2d in mono_jit_runtime_invoke (method=0x562c0bb61e50, obj=<optimized out>, params=0x7ffd50147450, exc=0x0, error=0x7ffd50147540) at mini-runtime.c:3082
#17 0x0000562c09a8e230 in do_runtime_invoke (method=0x562c0bb61e50, obj=<optimized out>, params=<optimized out>, exc=<optimized out>, error=0x7ffd50147540) at object.c:3010
#18 0x0000562c09a90aad in mono_runtime_invoke_handle (method=method@entry=0x562c0bb61e50, obj=..., obj@entry=..., params=params@entry=0x7ffd50147450, error=error@entry=0x7ffd50147540) at object.c:3184
#19 0x0000562c09a240a8 in create_exception_two_strings (klass=klass@entry=0x562c0bb60f00, a1=a1@entry=..., a2=..., a2@entry=..., error=error@entry=0x7ffd50147540) at exception.c:205
#20 0x0000562c09a24745 in mono_exception_from_name_two_strings_checked (image=<optimized out>, name_space=name_space@entry=0x562c09bc38e2 "System", name=name@entry=0x562c09ba4557 "OutOfMemoryException", a1=..., a2=a2@entry=..., error=error@entry=0x7ffd50147540) at exception.c:265
#21 0x0000562c099effad in create_domain_objects (domain=domain@entry=0x562c0bb0ca60) at appdomain.c:226
#22 0x0000562c099f26b8 in mono_runtime_init_checked (domain=domain@entry=0x562c0bb0ca60, start_cb=start_cb@entry=0x562c098893c0 <mono_thread_start_cb>, attach_cb=attach_cb@entry=0x562c09889430 <mono_thread_attach_cb>, error=error@entry=0x7ffd50147740) at appdomain.c:327
#23 0x0000562c09890c64 in mini_init (filename=<optimized out>, runtime_version=runtime_version@entry=0x0) at mini-runtime.c:4406
#24 0x0000562c098d59d1 in mono_main (argc=<optimized out>, argv=<optimized out>) at driver.c:2502
#25 0x0000562c09887bdc in mono_main_with_options (argv=<optimized out>, argc=<optimized out>) at main.c:50
#26 main (argc=<optimized out>, argv=<optimized out>) at main.c:408

=================================================================
	Basic Fault Adddress Reporting
=================================================================
Memory around native instruction pointer (0x7fad06288e97):0x7fad06288e87  d2 4c 89 ce bf 02 00 00 00 b8 0e 00 00 00 0f 05  .L..............
0x7fad06288e97  48 8b 8c 24 08 01 00 00 64 48 33 0c 25 28 00 00  H..$....dH3.%(..
0x7fad06288ea7  00 44 89 c0 75 1f 48 81 c4 18 01 00 00 c3 0f 1f  .D..u.H.........
0x7fad06288eb7  00 48 8b 15 a9 bf 3a 00 f7 d8 41 b8 ff ff ff ff  .H....:...A.....

=================================================================
	Managed Stacktrace:
=================================================================
=================================================================

Seems boned?

@alexanderkyte

This comment has been minimized.

Copy link
Member

@alexanderkyte alexanderkyte commented Apr 1, 2019

We've done a backport, and found the blamed commit is 352639f

@alexanderkyte

This comment has been minimized.

Copy link
Member

@alexanderkyte alexanderkyte commented Apr 1, 2019

Looks like a change made by @vargaz, I can look into it later today

@marek-safar marek-safar added this to the 2019-02 (6.0.xx) milestone Apr 1, 2019
@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Apr 1, 2019

@alexanderkyte 352639f is the cause of the mono_defaults problem with loadedllvm AOT in 5.20, and I've requested a backport of the fix.

I'll start tracking down this JIT issue, but bisecting is likely much harder since it hasn't worked in forever.

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Apr 3, 2019

Huh. Well, that's interesting.

Using in-tree LLVM rather than out-of-tree, does not throw the error from #12030 (comment) - it throws a different, exciting error: writing

gptrarray.c:118: assertion 'array != NULL' failed
gptrarray.c:118: assertion 'array != NULL' failed
gptrarray.c:118: assertion 'array != NULL' failed

forever.

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Apr 4, 2019

So, the problem is with out-of-tree loadedllvm (there's ANOTHER issue with in-tree; sigh)

It builds fine, but the assert is at https://github.com/mono/mono/blob/master/mono/mini/llvm-jit.cpp#L297 because the call to EB.selectTarget () returns null. Which is... not right. Trying to determine how & why that ends up being the case.

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Apr 4, 2019

I'm looking at 2 root causes, both of which are stupid as hell. Will report back.

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Apr 4, 2019

LLVM_TARGETS_TO_BUILD is cursed.

@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Apr 5, 2019

It looks like long cigarette drag this is a question of whether LLVM was built with LLVM_TARGETS_TO_BUILD="Native" or LLVM_TARGETS_TO_BUILD="X86" - even though those compile the same codegen engines.

Here's a sample program:

#include <llvm-c/Core.h>
#include <llvm-c/ExecutionEngine.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Support/Host.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/IR/Mangler.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/JITSymbol.h"

#include<iostream>  


using namespace std; 
using namespace llvm;
using namespace llvm::orc;
  
int main() 
{ 
InitializeNativeTarget ();
InitializeNativeTargetAsmPrinter();
EngineBuilder EB;
auto TM = EB.selectTarget ();
cout<<TM;
    return 0; 
}

Compiled thus:
g++ -I/usr/lib/mono/llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DLLVM_API_VERSION=610 -fno-rtti -fexceptions -std=c++11 -L/usr/lib/mono/llvm/lib argh.cpp -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMProfileData -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lLLVMOrcJIT -lLLVMTransformUtils -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMProfileData -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMX86Desc -lLLVMX86Info -lLLVMMCDisassembler -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lz -L/usr/lib/mono/llvm/lib -lrt -ldl -ltinfo -lpthread -lm

And the result:

directhex@breakfast:/tmp$ ls -lh a.out 
-rwxr-xr-x 1 directhex directhex 23M Apr  5 09:32 a.out
directhex@breakfast:/tmp$ ./a.out 
0x55d41b2c4920

Here's the SAME program, compiled with the SAME command line, against the SAME out-of-tree LLVM built with `LLVM_TARGETS_TO_BUILD="Native":

directhex@breakfast:/tmp$ ls -lh a.out 
-rwxr-xr-x 1 directhex directhex 2.8M Apr  5 09:35 a.out
directhex@breakfast:/tmp$ ./a.out 
0
@directhex

This comment has been minimized.

Copy link
Contributor Author

@directhex directhex commented Apr 8, 2019

FIXED IN MASTER \o/

I'll re-enable the LLVM JIT test in master now.

@directhex directhex closed this Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.