Crash on macOS - Assertion: should not be reached at metadata.c

Open
#1,197 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp, macos
Domain
tooling

Research direction

Start by reproducing the crash with CppSharp 0.9.0, Mono 5.18.0.268, and macOS, then inspect the ParserOptions constructor and the native metadata.c assertion shown in the stack trace. Done means identifying the compatibility or initialization cause and documenting a verified fix or regression coverage.

Written by the indexing model from the issue text.

Description

OS: macOS

I'm using the the nuget package (0.9.0 on macOS, CppSharp crashes the application with the following error:

* Assertion: should not be reached at metadata.c:2957


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

=================================================================
	Basic Fault Adddress Reporting
=================================================================
Memory around native instruction pointer (0x7fff6e15b23e):0x7fff6e15b22e  ff ff c3 90 90 90 b8 48 01 00 02 49 89 ca 0f 05  .......H...I....
0x7fff6e15b23e  73 08 48 89 c7 e9 6f a1 ff ff c3 55 48 89 e5 41  s.H...o....UH..A
0x7fff6e15b24e  57 41 56 41 55 41 54 53 48 81 ec 88 00 00 00 49  WAVAUATSH......I
0x7fff6e15b25e  89 f4 48 8d 05 01 93 ca 32 48 8b 00 48 8d 9d 60  ..H.....2H..H..`

=================================================================
	Native stacktrace:
=================================================================
	0x10b583d3d - /usr/local/bin/mono : mono_dump_native_crash_info
	0x10b534354 - /usr/local/bin/mono : mono_handle_native_crash
	0x7fff6e206b3d - /usr/lib/system/libsystem_platform.dylib : _sigtramp
	0x7f93e50562e8 - Unknown
	0x7fff6e0c41c9 - /usr/lib/system/libsystem_c.dylib : abort
	0x10b720460 - /usr/local/bin/mono : g_printv
	0x10b708574 - /usr/local/bin/mono : mono_log_write_logfile
	0x10b720737 - /usr/local/bin/mono : monoeg_g_logv_nofree
	0x10b720890 - /usr/local/bin/mono : monoeg_assertion_message
	0x10b636324 - /usr/local/bin/mono : collect_type_images
	0x10b6361ce - /usr/local/bin/mono : mono_metadata_get_image_set_for_class
	0x10b5f6056 - /usr/local/bin/mono : mono_class_create_ptr
	0x10b5eb118 - /usr/local/bin/mono : mono_class_from_mono_type
	0x10b64ffe8 - /usr/local/bin/mono : mono_class_vtable_checked
	0x10b64f408 - /usr/local/bin/mono : mono_runtime_class_init_full
	0x10b4a3f7e - /usr/local/bin/mono : mono_jit_compile_method_inner
	0x10b4a6f7c - /usr/local/bin/mono : mono_jit_compile_method_with_opt
	0x10b5370df - /usr/local/bin/mono : common_call_trampoline
	0x10b536b72 - /usr/local/bin/mono : mono_magic_trampoline
	0x10b8ca393 - Unknown
	0x10b9a7683 - Unknown
	0x10b9a2fe3 - Unknown
	0x10b9a3179 - Unknown
	0x10b4aaf93 - /usr/local/bin/mono : mono_jit_runtime_invoke
	0x10b652f8d - /usr/local/bin/mono : do_runtime_invoke
	0x10b656145 - /usr/local/bin/mono : do_exec_main_checked
	0x10b4fe4aa - /usr/local/bin/mono : mono_jit_exec
	0x10b501188 - /usr/local/bin/mono : mono_main
	0x10b49cafa - /usr/local/bin/mono : main
	0x7fff6e01bed9 - /usr/lib/system/libdyld.dylib : start
	0x2 - Unknown

=================================================================
	Telemetry Dumper:
=================================================================
Pkilling 0x70000e819000 from 0x110ea75c0
Entering thread summarizer pause from 0x110ea75c0
Finished thread summarizer pause from 0x110ea75c0.

Waiting for dumping threads to resume

Debug info from gdb:


=================================================================
	External Debugger Dump:
=================================================================
(lldb) command source -s 0 '/tmp/mono-gdb-commands.59065'
Executing commands in '/tmp/mono-gdb-commands.59065'.
(lldb) process attach --pid 59065
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
    import weakref
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Process 59065 stopped
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00007fff6e15a2d2 libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
->  0x7fff6e15a2d2 <+10>: jae    0x7fff6e15a2dc            ; <+20>
    0x7fff6e15a2d4 <+12>: movq   %rax, %rdi
    0x7fff6e15a2d7 <+15>: jmp    0x7fff6e155381            ; cerror
    0x7fff6e15a2dc <+20>: retq   
Target 0: (mono) stopped.

Executable module set to "/usr/local/bin/mono".
Architecture set to: x86_64h-apple-macosx.
(lldb) thread list
Process 59065 stopped
* thread #1: tid = 0x3ac5f4, 0x00007fff6e15a2d2 libsystem_kernel.dylib`__wait4 + 10, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  thread #2: tid = 0x3ac5f7, 0x00007fff6e1587de libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
  thread #3: tid = 0x3ac5f8, 0x00007fff6e1551b6 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
(lldb) thread backtrace all
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff6e15a2d2 libsystem_kernel.dylib`__wait4 + 10
    frame #1: 0x000000010b583f94 mono`mono_dump_native_crash_info + 865
    frame #2: 0x000000010b534354 mono`mono_handle_native_crash + 212
    frame #3: 0x00007fff6e206b3d libsystem_platform.dylib`_sigtramp + 29
    frame #4: 0x00007fff6e15b23f libsystem_kernel.dylib`__pthread_kill + 11
    frame #5: 0x00007fff6e211c1c libsystem_pthread.dylib`pthread_kill + 285
    frame #6: 0x00007fff6e0c41c9 libsystem_c.dylib`abort + 127
    frame #7: 0x000000010b720460 mono`monoeg_assert_abort + 23
    frame #8: 0x000000010b708574 mono`mono_log_write_logfile + 319
    frame #9: 0x000000010b720737 mono`monoeg_g_logv_nofree + 187
    frame #10: 0x000000010b720890 mono`monoeg_assertion_message + 124
    frame #11: 0x000000010b636324 mono`collect_type_images + 289
    frame #12: 0x000000010b6361ce mono`mono_metadata_get_image_set_for_class + 60
    frame #13: 0x000000010b5f6056 mono`mono_class_create_ptr + 68
    frame #14: 0x000000010b5eb118 mono`mono_class_from_mono_type + 618
    frame #15: 0x000000010b64ffe8 mono`mono_class_vtable_checked + 1165
    frame #16: 0x000000010b64f408 mono`mono_runtime_class_init_full + 281
    frame #17: 0x000000010b4a3f7e mono`mono_jit_compile_method_inner + 1039
    frame #18: 0x000000010b4a6f7c mono`mono_jit_compile_method_with_opt + 2384
    frame #19: 0x000000010b5370df mono`common_call_trampoline + 1301
    frame #20: 0x000000010b536b72 mono`mono_magic_trampoline + 106
    frame #21: 0x000000010b8ca393
    frame #22: 0x000000010b9a7683
    frame #23: 0x000000010b9a2fe3
    frame #24: 0x000000010b9a3179
    frame #25: 0x000000010b4aaf93 mono`mono_jit_runtime_invoke + 1543
    frame #26: 0x000000010b652f8d mono`do_runtime_invoke + 80
    frame #27: 0x000000010b656145 mono`do_exec_main_checked + 90
    frame #28: 0x000000010b4fe4aa mono`mono_jit_exec + 366
    frame #29: 0x000000010b501188 mono`mono_main + 10421
    frame #30: 0x000000010b49cafa mono`main + 258
    frame #31: 0x00007fff6e01bed9 libdyld.dylib`start + 1
  thread #2, name = 'SGen worker'
    frame #0: 0x00007fff6e1587de libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff6e212593 libsystem_pthread.dylib`_pthread_cond_wait + 724
    frame #2: 0x000000010b70044f mono`thread_func + 485
    frame #3: 0x00007fff6e20f305 libsystem_pthread.dylib`_pthread_body + 126
    frame #4: 0x00007fff6e21226f libsystem_pthread.dylib`_pthread_start + 70
    frame #5: 0x00007fff6e20e415 libsystem_pthread.dylib`thread_start + 13
  thread #3, name = 'Finalizer'
    frame #0: 0x00007fff6e1551b6 libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x000000010b6badd1 mono`finalizer_thread + 351
    frame #2: 0x000000010b6734f6 mono`start_wrapper_internal + 335
    frame #3: 0x000000010b673386 mono`start_wrapper + 71
    frame #4: 0x00007fff6e20f305 libsystem_pthread.dylib`_pthread_body + 126
    frame #5: 0x00007fff6e21226f libsystem_pthread.dylib`_pthread_start + 70
    frame #6: 0x00007fff6e20e415 libsystem_pthread.dylib`thread_start + 13
(lldb) detach
Process 59065 detached
(lldb) quit

=================================================================
	Managed Stacktrace:
=================================================================
	  at <unknown> <0xffffffff>
	  at CppSharp.Parser.ParserOptions:.ctor <0x00022>
	  at CppSharp.Driver:.ctor <0x0005a>
	  at CppSharp.ConsoleDriver:Run <0x00162>
	  at Test.MainClass:Main <0x00042>
	  at <Module>:runtime_invoke_void_object <0x000d8>
=================================================================
Abort trap: 6

I'm running mono 5.18.0.268...

Any help would be greatly appreciated :)

Dominant language
C#
Stars
3.4k
Forks
541
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mono/CppSharp

All issues in mono/CppSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.