Bug 47152 - AOT attempts at Xamarin.Mac.dll crash mono
Summary: AOT attempts at Xamarin.Mac.dll crash mono
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-16 22:31 UTC by Chris Hamons
Modified: 2016-11-27 03:49 UTC (History)
4 users (show)

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


Attachments
File in question (800.00 KB, application/x-msdownload)
2016-11-16 22:31 UTC, Chris Hamons
Details


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 Chris Hamons 2016-11-16 22:31:55 UTC
Created attachment 18492 [details]
File in question

I've attached the assembly in question

$ mono --version
Mono JIT compiler version 4.9.0 (master/693bffd Wed Nov 16 13:46:22 EST 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       altstack
        Notification:  kqueue
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug 
        LLVM:          yes(3.6.0svn-mono-master/8b1520c)
        GC:            sgen (concurrent by default)
donblas:~/Programming/mac-samples/NSOutlineViewAndTabl

$ mono --aot Xamarin.Mac.dll
Mono Ahead of Time compiler - compiling assembly /Users/donblas/Programming/mac-samples/NSOutlineViewAndTableView/NSOutlineViewAndTableViewExample/bin/Debug/NSOutlineViewAndTableViewExample.app/Contents/MonoBundle/Xamarin.Mac.dll
AOTID 4B9E7E48-3751-5130-BF11-88CA9B076464
* Assertion at mini-native-types.c:414, condition `t->type == mini_native_type_replace_type (&klass->byval_arg)->type' not met

Stacktrace:


Native stacktrace:

        0   mono                                0x001811c6 mono_handle_native_sigsegv + 342
        1   mono                                0x001d6491 sigabrt_signal_handler + 145
        2   libsystem_platform.dylib            0x9657f79b _sigtramp + 43
        3   ???                                 0xffffffff 0x0 + 4294967295
        4   libsystem_c.dylib                   0x96aecc38 abort + 156
        5   mono                                0x0033b6dc mono_log_write_logfile + 380
        6   mono                                0x00335f92 structured_log_adapter + 50
        7   mono                                0x0035337b monoeg_assertion_message + 107
        8   mono                                0x00196439 mono_class_is_magic_float + 345
        9   mono                                0x0019653d mini_native_type_replace_type + 253
        10  mono                                0x0018c6ba mini_type_get_underlying_type + 26
        11  mono                                0x000b1c37 mono_compile_create_var + 23
        12  mono                                0x000b54d5 mini_method_compile + 3589
        13  mono                                0x0016047c compile_method + 524
        14  mono                                0x00150edc mono_compile_assembly + 13900
        15  mono                                0x00146a8e mono_main + 9054
        16  mono                                0x000b01cb main + 2011
        17  mono                                0x000af9e5 start + 53

Debug info from gdb:

(lldb) command source -s 0 '/tmp/mono-gdb-commands.Ia30k5'
Executing commands in '/tmp/mono-gdb-commands.Ia30k5'.
(lldb) process attach --pid 45551
Process 45551 stopped
* thread #1: tid = 0x1658b6f, 0x9659fcee libsystem_kernel.dylib`__wait4 + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x9659fcee libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
->  0x9659fcee <+10>: jae    0x9659fcfe                ; <+26>
    0x9659fcf0 <+12>: calll  0x9659fcf5                ; <+17>
    0x9659fcf5 <+17>: popl   %edx
    0x9659fcf6 <+18>: movl   0xce5932f(%edx), %edx

Executable module set to "/usr/local/bin/mono".
Architecture set to: i386-apple-macosx.
(lldb) thread list
Process 45551 stopped
* thread #1: tid = 0x1658b6f, 0x9659fcee libsystem_kernel.dylib`__wait4 + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  thread #2: tid = 0x1658b70, 0x9659f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
  thread #3: tid = 0x1658b71, 0x965984d6 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
  thread #4: tid = 0x1658b72, 0x9659fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
  thread #5: tid = 0x1658b73, 0x965a07fa libsystem_kernel.dylib`kevent_qos + 10, queue = 'com.apple.libdispatch-manager'
(lldb) thread backtrace all
* thread #1: tid = 0x1658b6f, 0x9659fcee libsystem_kernel.dylib`__wait4 + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x9659fcee libsystem_kernel.dylib`__wait4 + 10
    frame #1: 0x96b0c7e0 libsystem_c.dylib`waitpid$UNIX2003 + 48
    frame #2: 0x0018128d mono`mono_handle_native_sigsegv(signal=6, ctx=0xbff5225c, info=0xbff5221c) + 541 at mini-exceptions.c:2429 [opt]
    frame #3: 0x001d6491 mono`sigabrt_signal_handler(_dummy=<unavailable>, _info=<unavailable>, context=<unavailable>) + 145 at mini-posix.c:223 [opt]

  thread #2: tid = 0x1658b70, 0x9659f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
    frame #0: 0x9659f3ea libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x95287538 libsystem_pthread.dylib`_pthread_cond_wait + 757
    frame #2: 0x95289276 libsystem_pthread.dylib`pthread_cond_wait$UNIX2003 + 71
    frame #3: 0x003266ef mono`thread_func [inlined] mono_os_cond_wait(mutex=0x0042a250) + 18 at mono-os-mutex.h:146 [opt]
    frame #4: 0x003266dd mono`thread_func(thread_data=<unavailable>) + 189 at sgen-thread-pool.c:110 [opt]
    frame #5: 0x95286780 libsystem_pthread.dylib`_pthread_body + 138
    frame #6: 0x952866f6 libsystem_pthread.dylib`_pthread_start + 155
    frame #7: 0x95283f7a libsystem_pthread.dylib`thread_start + 34

  thread #3: tid = 0x1658b71, 0x965984d6 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
    frame #0: 0x965984d6 libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x002b7c6e mono`finalizer_thread [inlined] mono_os_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) + 14 at mono-os-semaphore.h:90 [opt]
    frame #2: 0x002b7c60 mono`finalizer_thread [inlined] mono_coop_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) + 10 at mono-coop-semaphore.h:40 [opt]
    frame #3: 0x002b7c56 mono`finalizer_thread(unused=0x00000000) + 214 at gc.c:907 [opt]
    frame #4: 0x0028a384 mono`start_wrapper [inlined] start_wrapper_internal + 322 at threads.c:862 [opt]
    frame #5: 0x0028a242 mono`start_wrapper(data=<unavailable>) + 18 at threads.c:913 [opt]
    frame #6: 0x003488f7 mono`inner_start_thread(data=<unavailable>) + 455 at mono-threads.c:1133 [opt]
    frame #7: 0x95286780 libsystem_pthread.dylib`_pthread_body + 138
    frame #8: 0x952866f6 libsystem_pthread.dylib`_pthread_start + 155
    frame #9: 0x95283f7a libsystem_pthread.dylib`thread_start + 34

  thread #4: tid = 0x1658b72, 0x9659fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x9659fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x9528634b libsystem_pthread.dylib`_pthread_wqthread + 1289
    frame #2: 0x95283f56 libsystem_pthread.dylib`start_wqthread + 34

  thread #5: tid = 0x1658b73, 0x965a07fa libsystem_kernel.dylib`kevent_qos + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x965a07fa libsystem_kernel.dylib`kevent_qos + 10
    frame #1: 0x943ff7ea libdispatch.dylib`_dispatch_mgr_invoke + 234
    frame #2: 0x943ff3be libdispatch.dylib`_dispatch_mgr_thread + 52
(lldb) detach

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

Process 45551 detached
(lldb) Abort trap: 6




$ mono --aot=hybrid Xamarin.Mac.dll
Mono Ahead of Time compiler - compiling assembly /Users/donblas/Programming/mac-samples/NSOutlineViewAndTableView/NSOutlineViewAndTableViewExample/bin/Debug/NSOutlineViewAndTableViewExample.app/Contents/MonoBundle/Xamarin.Mac.dll
AOTID EA95FEDF-AD06-7CA1-558C-2236E72BC50C
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field System.Collections.Generic.Queue`1+Enumerator[Foundation.NSData]:_q
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream:data
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream:data
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream:data
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream:data
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream:data
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream:data
Invalid type Foundation.NSUrlSessionHandler/NSUrlSessionDataTaskStream for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream+<ReadAsync>c__async0:$this
Invalid type Foundation.NSUrlSessionHandler/NSUrlSessionDataTaskStream for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream+<ReadAsync>c__async0:$this
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream:data
Invalid type System.Collections.Generic.Queue`1<Foundation.NSData> for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream:data
Invalid type Foundation.NSUrlSessionHandler/NSUrlSessionDataTaskStream for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream+<ReadAsync>c__async0:$this
Invalid type Foundation.NSUrlSessionHandler/NSUrlSessionDataTaskStream for instance field Foundation.NSUrlSessionHandler+NSUrlSessionDataTaskStream+<ReadAsync>c__async0:$this
* Assertion at mini-native-types.c:414, condition `t->type == mini_native_type_replace_type (&klass->byval_arg)->type' not met

Stacktrace:


Native stacktrace:

        0   mono                                0x001121c6 mono_handle_native_sigsegv + 342
        1   mono                                0x00167491 sigabrt_signal_handler + 145
        2   libsystem_platform.dylib            0x9657f79b _sigtramp + 43
        3   ???                                 0xffffffff 0x0 + 4294967295
        4   libsystem_c.dylib                   0x96aecc38 abort + 156
        5   mono                                0x002cc6dc mono_log_write_logfile + 380
        6   mono                                0x002c6f92 structured_log_adapter + 50
        7   mono                                0x002e437b monoeg_assertion_message + 107
        8   mono                                0x00127439 mono_class_is_magic_float + 345
        9   mono                                0x0012753d mini_native_type_replace_type + 253
        10  mono                                0x0011d6ba mini_type_get_underlying_type + 26
        11  mono                                0x00042c37 mono_compile_create_var + 23
        12  mono                                0x000464d5 mini_method_compile + 3589
        13  mono                                0x000f147c compile_method + 524
        14  mono                                0x000e1edc mono_compile_assembly + 13900
        15  mono                                0x000d7a8e mono_main + 9054
        16  mono                                0x000411cb main + 2011
        17  mono                                0x000409e5 start + 53
        18  ???                                 0x00000003 0x0 + 3

Debug info from gdb:

(lldb) command source -s 0 '/tmp/mono-gdb-commands.6FdQ7A'
Executing commands in '/tmp/mono-gdb-commands.6FdQ7A'.
(lldb) process attach --pid 45571
^CProcess 45571 stopped
* thread #1: tid = 0x165911c, 0x9659fcee libsystem_kernel.dylib`__wait4 + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x9659fcee libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
->  0x9659fcee <+10>: jae    0x9659fcfe                ; <+26>
    0x9659fcf0 <+12>: calll  0x9659fcf5                ; <+17>
    0x9659fcf5 <+17>: popl   %edx
    0x9659fcf6 <+18>: movl   0xce5932f(%edx), %edx

Executable module set to "/usr/local/bin/mono".
Architecture set to: i386-apple-macosx.
(lldb) thread list
Process 45571 stopped
* thread #1: tid = 0x165911c, 0x9659fcee libsystem_kernel.dylib`__wait4 + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  thread #2: tid = 0x165911f, 0x9659f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
  thread #3: tid = 0x1659120, 0x965984d6 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
  thread #4: tid = 0x1659121, 0x9659fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
  thread #5: tid = 0x1659122, 0x965a07fa libsystem_kernel.dylib`kevent_qos + 10, queue = 'com.apple.libdispatch-manager'
(lldb) thread backtrace all
* thread #1: tid = 0x165911c, 0x9659fcee libsystem_kernel.dylib`__wait4 + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x9659fcee libsystem_kernel.dylib`__wait4 + 10
    frame #1: 0x96b0c7e0 libsystem_c.dylib`waitpid$UNIX2003 + 48
    frame #2: 0x0011228d mono`mono_handle_native_sigsegv(signal=6, ctx=0xbffc124c, info=0xbffc120c) + 541 at mini-exceptions.c:2429 [opt]
    frame #3: 0x00167491 mono`sigabrt_signal_handler(_dummy=<unavailable>, _info=<unavailable>, context=<unavailable>) + 145 at mini-posix.c:223 [opt]
    frame #4: 0x9657f79b libsystem_platform.dylib`_sigtramp + 43

  thread #2: tid = 0x165911f, 0x9659f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
    frame #0: 0x9659f3ea libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x95287538 libsystem_pthread.dylib`_pthread_cond_wait + 757
    frame #2: 0x95289276 libsystem_pthread.dylib`pthread_cond_wait$UNIX2003 + 71
    frame #3: 0x002b76ef mono`thread_func [inlined] mono_os_cond_wait(mutex=0x003bb250) + 18 at mono-os-mutex.h:146 [opt]
    frame #4: 0x002b76dd mono`thread_func(thread_data=<unavailable>) + 189 at sgen-thread-pool.c:110 [opt]
    frame #5: 0x95286780 libsystem_pthread.dylib`_pthread_body + 138
    frame #6: 0x952866f6 libsystem_pthread.dylib`_pthread_start + 155
    frame #7: 0x95283f7a libsystem_pthread.dylib`thread_start + 34

  thread #3: tid = 0x1659120, 0x965984d6 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
    frame #0: 0x965984d6 libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x00248c6e mono`finalizer_thread [inlined] mono_os_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) + 14 at mono-os-semaphore.h:90 [opt]
    frame #2: 0x00248c60 mono`finalizer_thread [inlined] mono_coop_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) + 10 at mono-coop-semaphore.h:40 [opt]
    frame #3: 0x00248c56 mono`finalizer_thread(unused=0x00000000) + 214 at gc.c:907 [opt]
    frame #4: 0x0021b384 mono`start_wrapper [inlined] start_wrapper_internal + 322 at threads.c:862 [opt]
    frame #5: 0x0021b242 mono`start_wrapper(data=<unavailable>) + 18 at threads.c:913 [opt]
    frame #6: 0x002d98f7 mono`inner_start_thread(data=<unavailable>) + 455 at mono-threads.c:1133 [opt]
    frame #7: 0x95286780 libsystem_pthread.dylib`_pthread_body + 138
    frame #8: 0x952866f6 libsystem_pthread.dylib`_pthread_start + 155
    frame #9: 0x95283f7a libsystem_pthread.dylib`thread_start + 34

  thread #4: tid = 0x1659121, 0x9659fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x9659fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x9528634b libsystem_pthread.dylib`_pthread_wqthread + 1289
    frame #2: 0x95283f56 libsystem_pthread.dylib`start_wqthread + 34

  thread #5: tid = 0x1659122, 0x965a07fa libsystem_kernel.dylib`kevent_qos + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x965a07fa libsystem_kernel.dylib`kevent_qos + 10
    frame #1: 0x943ff7ea libdispatch.dylib`_dispatch_mgr_invoke + 234
    frame #2: 0x943ff3be libdispatch.dylib`_dispatch_mgr_thread + 52
(lldb) detach

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

Process 45571 detached
Comment 1 Rodrigo Kumpera 2016-11-17 19:09:48 UTC
You're AOT'ing a Xamarin.Mac.dll with the wrong bitness. Assemblies that contains the definition of native types are 32/64 bits specific.

My suggestion is that you use mono32 and mono64 to properly control that.
Comment 2 Chris Hamons 2016-11-17 19:14:08 UTC
@Kumpera. Doh. My bad.

Still crashes when I use mono64 correctly though.

https://gist.github.com/chamons/36ad7da86c393d940e62563071ca261d

Am I doing something else wrong?
Comment 3 Zoltan Varga 2016-11-22 20:08:06 UTC
This means the runtime doesn't match the Xamarin.Mac.dll assembly, i.e. the runtime is 64 bit while xam.mac.dll is 32 bit etc.
Comment 4 Zoltan Varga 2016-11-22 20:40:18 UTC
MONO_LOG_LEVEL=debug prints out more information, i.e.:

Mono: no implementation for interface method System.Collections.ICollection::get_IsSynchronized() in class Foundation.NSDictionary
Comment 5 Zoltan Varga 2016-11-27 03:49:24 UTC
Added a more descriptive assertion + error checking so we shouldn't crash anymore.