简体   繁体   中英

Nunit on Mono (OSX) will not run tests - mono_defaults.runtimetype_class != 0

I'm trying to run some basic tests using Nunit on OSX.

mono --version

Mono JIT compiler version 4.2.1 (explicit/6dd2d0d Tue Nov 10 18:01:18 EST 2015)

Nunit:

which nunit-console

/usr/local/bin/nunit-console

Also Nunit4:

which nunit-console4

/usr/local/bin/nunit-console4

I'm trying to run a basic test library using the following:

nunit-console Tests.dll

But I'm getting the following trace:

* Assertion at domain.c:718, condition `mono_defaults.runtimetype_class != 0' not met


Native stacktrace:

    0   mono                                0x000c91c6 mono_handle_native_sigsegv + 342
    1   mono                                0x001198d1 sigabrt_signal_handler + 129
    2   libsystem_platform.dylib            0x95d9101b _sigtramp + 43
    3   ???                                 0xffffffff 0x0 + 4294967295
    4   libsystem_c.dylib                   0x90304c34 abort + 156
    5   mono                                0x0026dd11 monoeg_log_default_handler + 129
    6   mono                                0x0026de0b monoeg_assertion_message + 107
    7   mono                                0x001d8f04 mono_init_internal + 5860
    8   mono                                0x001d92b8 mono_init_from_assembly + 24
    9   mono                                0x00017c6f mini_init + 2063
    10  mono                                0x000937e0 mono_main + 4912
    11  mono                                0x0000c690 main + 768
    12  mono                                0x0000c385 start + 53
    13  ???                                 0x00000004 0x0 + 4

Debug info from gdb:

(lldb) command source -s 0 '/tmp/mono-gdb-commands.7rUr4M'
Executing commands in '/tmp/mono-gdb-commands.7rUr4M'.
(lldb) process attach --pid 6044
Process 6044 stopped
* thread #1: tid = 0x403d0, 0x993ced06 libsystem_kernel.dylib`__wait4 + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x993ced06 libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
->  0x993ced06 <+10>: jae    0x993ced16                ; <+26>
    0x993ced08 <+12>: calll  0x993ced0d                ; <+17>
    0x993ced0d <+17>: popl   %edx
    0x993ced0e <+18>: movl   0xab94317(%edx), %edx

Executable module set to "/Library/Frameworks/Mono.framework/Versions/4.2.1/bin/mono".
Architecture set to: i386-apple-macosx.
(lldb) thread list
Process 6044 stopped
* thread #1: tid = 0x403d0, 0x993ced06 libsystem_kernel.dylib`__wait4 + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  thread #2: tid = 0x403d8, 0x993ce402 libsystem_kernel.dylib`__psynch_cvwait + 10
(lldb) thread backtrace all
* thread #1: tid = 0x403d0, 0x993ced06 libsystem_kernel.dylib`__wait4 + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x993ced06 libsystem_kernel.dylib`__wait4 + 10
    frame #1: 0x903247dc libsystem_c.dylib`waitpid$UNIX2003 + 48
    frame #2: 0x000c928d mono`mono_handle_native_sigsegv(signal=6, ctx=0xbfff62ac, info=0xbfff626c) + 541 at mini-exceptions.c:2193 [opt]
    frame #3: 0x001198d1 mono`sigabrt_signal_handler(_dummy=<unavailable>, _info=<unavailable>, context=<unavailable>) + 129 at mini-posix.c:208 [opt]
    frame #4: 0x95d9101b libsystem_platform.dylib`_sigtramp + 43
    frame #5: 0x993ce58b libsystem_kernel.dylib`__pthread_kill + 11
    frame #6: 0x91ef3448 libsystem_pthread.dylib`pthread_kill + 101
    frame #7: 0x90304c34 libsystem_c.dylib`abort + 156
    frame #8: 0x0026dd11 mono`monoeg_log_default_handler(log_domain=<unavailable>, log_level=<unavailable>, message=<unavailable>, unused_data=<unavailable>) + 129 at goutput.c:233 [opt]
    frame #9: 0x0026de0b mono`monoeg_assertion_message [inlined] monoeg_g_logv(log_level=G_LOG_LEVEL_ERROR, format=<unavailable>) + 85 at goutput.c:113 [opt]
    frame #10: 0x0026ddb6 mono`monoeg_assertion_message(format=<unavailable>) + 22 at goutput.c:133 [opt]
    frame #11: 0x001d8f04 mono`mono_init_internal(filename=<unavailable>, exe_filename=<unavailable>, runtime_version=<unavailable>) + 5860 at domain.c:718 [opt]
    frame #12: 0x001d92b8 mono`mono_init_from_assembly(domain_name="/Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5/nunit-console.exe", filename="/Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5/nunit-console.exe") + 24 at domain.c:893 [opt]
    frame #13: 0x00017c6f mono`mini_init(filename=<unavailable>, runtime_version=<unavailable>) + 2063 at mini-runtime.c:3069 [opt]
    frame #14: 0x000937e0 mono`mono_main(argc=4, argv=0xbfff6740) + 4912 at driver.c:1907 [opt]
    frame #15: 0x0000c690 mono`main [inlined] mono_main_with_options(argc=<unavailable>, argv=<unavailable>) + 768 at main.c:94 [opt]
    frame #16: 0x0000c3ad mono`main(argc=<unavailable>, argv=<unavailable>) + 29 at main.c:125 [opt]
    frame #17: 0x0000c385 mono`start + 53

  thread #2: tid = 0x403d8, 0x993ce402 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #0: 0x993ce402 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x91ef1f6b libsystem_pthread.dylib`_pthread_cond_wait + 757
    frame #2: 0x91ef5cc0 libsystem_pthread.dylib`pthread_cond_wait$UNIX2003 + 71
    frame #3: 0x0023c852 mono`thread_func(thread_data=0x00000000) + 466 at sgen-thread-pool.c:118 [opt]
    frame #4: 0x91ef1a26 libsystem_pthread.dylib`_pthread_body + 138
    frame #5: 0x91ef199c libsystem_pthread.dylib`_pthread_start + 155
    frame #6: 0x91eeef96 libsystem_pthread.dylib`thread_start + 34
(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 6044 detached
(lldb) quit
[1]    6044 abort      nunit-console Tests.dll

I don't believe it's a problem with my tests as it throws the same trace when only trying to open Nunit-console with the help argument:

nunit-console4 --help

I can see that it's being thrown on line 718 of the file here:

https://github.com/mono/mono/blob/master/mono/metadata/domain.c

mono_defaults.runtimetype_class = mono_class_from_name (
            mono_defaults.corlib, "System", "RuntimeType");
g_assert (mono_defaults.runtimetype_class != 0);

I'm kinda lost at this point as the error isn't very verbose - to me it feels like there is a problem with my configuration that's preventing Nunit from starting properly.

Thanks

You may need to reinstall/update Mono. I'm running a slightly newer version and I can confirm that

nunit-console --help

runs just fine on my system with the following versions -

mono --version
Mono JIT compiler version 4.2.1 (Stable 4.2.1.102/6dd2d0d Wed Dec  2 14:02:16 PST 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug
    LLVM:          supported, not enabled.
    GC:            sgen

and runtime

dnvm list

Active Version              Runtime Arch Location             Alias
------ -------              ------- ---- --------             -----
       1.0.0-beta4          mono         ~/.dnx/runtimes
  *    1.0.0-rc1-update1    mono         ~/.dnx/runtimes      default

EDIT: nunit-console script

#!/bin/sh
exec /usr/local/Cellar/mono/4.2.1.102_1/bin/mono --debug $MONO_OPTIONS /usr/local/Cellar/mono/4.2.1.102_1/lib/mono/4.5/nunit-console.exe "$@"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM