Using Mono 4.6.1 and Xamarin Studio [Community] running on MBP with OSX 10.11.6
I have a Solution, with two projects; one is the .NET project, the other NUnit test project for the first. When I mock an interface which uses auto properties (using Moq or NSubstitute) it causes mono to crash (SIGSTOP) during debugging.
public interface IExample
{
string Name { get; }
}
[TestFixture]
public class Test
{
[Test]
public void TestCase()
{
var example = Substitute.For<IExample>();
example.Name.Returns("Hat");
Console.WriteLine(example.Name);
}
}
If I put a breakpoint on the first line which creates the example substitute the system waits as expected. If I step over that line after about 1-2 seconds the system crashes (details below). NB: Running the test causes the test to pass because it doesn't take long enough for the background failure to trigger.
Application Output of failure:
Loaded assembly: /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.UnitTesting/NUnit2/NUnitRunner.exe
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
Loaded assembly: /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.UnitTesting/NUnit2/nunit.core.interfaces.dll
Loaded assembly: /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.UnitTesting/NUnit2/nunit.core.dll
Loaded assembly: /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.UnitTesting/NUnit2/nunit.framework.dll
Loaded assembly: /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.UnitTesting/NUnit2/nunit.util.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/System.Runtime.Remoting/4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
Thread started: #2
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
Thread started: #3
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/nunit.util/2.4.8.0__96d09a1eb7f44a77/nunit.util.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/nunit.core.interfaces/2.4.8.0__96d09a1eb7f44a77/nunit.core.interfaces.dll
Thread started: #7
Loaded assembly: /Users/jeremy.connor/dev/MonoAPBug/MonoAPBug.Tests/bin/Debug/MonoAPBug.Tests.dll
Thread started: EventPumpThread #8
Thread started: TestRunnerThread #9
Resolved pending breakpoint at 'Test.cs:13,1' to void MonoAPBug.Tests.Test.TestCase () [0x00001].
Loaded assembly: /Users/jeremy.connor/dev/MonoAPBug/MonoAPBug.Tests/bin/Debug/MonoAPBug.exe
Loaded assembly: /Users/jeremy.connor/dev/MonoAPBug/MonoAPBug.Tests/bin/Debug/NSubstitute.dll
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/4.6.1/lib/mono/gac/System.ServiceModel/4.0.0.0__b77a5c561934e089/System.ServiceModel.dll
Loaded assembly: DynamicProxyGenAssembly2
Loaded assembly: DynamicProxyGenAssembly2
mono(10800,0xb0319000) malloc: *** error for object 0x77c2a0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Stacktrace:
Native stacktrace:
0 mono 0x00171e46 mono_handle_native_sigsegv + 342
1 mono 0x001c5091 sigabrt_signal_handler + 145
2 libsystem_platform.dylib 0x91d4579b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 libsystem_c.dylib 0x98fdcc38 abort + 156
5 libsystem_malloc.dylib 0x96e51292 free + 433
6 mono 0x0032b266 mono_error_cleanup + 102
7 mono 0x001a7bda type_commands_internal + 2970
8 mono 0x0019b97d debugger_thread + 5261
9 mono 0x003340ca inner_start_thread + 474
10 libsystem_pthread.dylib 0x96e06780 _pthread_body + 138
11 libsystem_pthread.dylib 0x96e066f6 _pthread_body + 0
12 libsystem_pthread.dylib 0x96e03f7a thread_start + 34
Debug info from gdb:
(lldb) command source -s 0 '/tmp/mono-gdb-commands.TQtGVg'
Executing commands in '/tmp/mono-gdb-commands.TQtGVg'.
(lldb) process attach --pid 10800
Process 10800 stopped
* thread #1: tid = 0x211a96, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10
libsystem_kernel.dylib`__psynch_cvwait:
-> 0x9386f3ea <+10>: jae 0x9386f3fa ; <+26>
0x9386f3ec <+12>: calll 0x9386f3f1 ; <+17>
0x9386f3f1 <+17>: popl %edx
0x9386f3f2 <+18>: movl 0xf8cdc2f(%edx), %edx
Executable module set to "/Library/Frameworks/Mono.framework/Versions/4.6.1/bin/mono".
Architecture set to: i386-apple-macosx.
(lldb) thread list
Process 10800 stopped
* thread #1: tid = 0x211a96, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
thread #2: tid = 0x211a98, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
thread #3: tid = 0x211a9a, 0x938684d6 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
thread #4: tid = 0x211a9b, 0x9386fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
thread #5: tid = 0x211a9c, 0x938707fa libsystem_kernel.dylib`kevent_qos + 10, queue = 'com.apple.libdispatch-manager'
thread #6: tid = 0x211a9d, 0x9386fcee libsystem_kernel.dylib`__wait4 + 10, name = 'Debugger agent'
thread #7: tid = 0x211aa1, 0x9386fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
thread #8: tid = 0x211aa5, 0x9386fd5e libsystem_kernel.dylib`__workq_kernreturn + 10
thread #9: tid = 0x211aa8, 0x9386e852 libsystem_kernel.dylib`__accept + 10, name = 'tid_2507'
thread #10: tid = 0x211aa9, 0x9386f646 libsystem_kernel.dylib`__recvfrom + 10, name = 'tid_2b0b'
thread #11: tid = 0x211aaa, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'tid_330b'
thread #12: tid = 0x211aab, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'Threadpool worker'
thread #13: tid = 0x211aac, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'Threadpool worker'
thread #14: tid = 0x211aad, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'Timer-Scheduler'
thread #15: tid = 0x211aaf, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'EventPumpThread'
thread #16: tid = 0x211ab0, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'TestRunnerThread'
(lldb) thread backtrace all
* thread #1: tid = 0x211a96, 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'tid_50b', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x9386f3ea libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0x96e07538 libsystem_pthread.dylib`_pthread_cond_wait + 757
frame #2: 0x96e09276 libsystem_pthread.dylib`pthread_cond_wait$UNIX2003 + 71
frame #3: 0x0030a955 mono`mono_os_cond_timedwait [inlined] mono_os_cond_wait(cond=0x7a138238, mutex=0x7a13820c) + 12 at mono-os-mutex.h:107 [opt]
frame #4: 0x0030a949 mono`mono_os_cond_timedwait(cond=<unavailable>, mutex=<unavailable>, timeout_ms=<unavailable>) + 185 at mono-os-mutex.h:122 [opt]
frame #5: 0x0030a6cb mono`_wapi_handle_timedwait_signal_handle(handle=0x00001600, timeout=<unavailable>, alertable=<unavailable>, poll=<unavailable>, alerted=0xbff5e390) + 507 at handles.c:1555 [opt]
frame #6: 0x0030a4c8 mono`_wapi_handle_timedwait_signal(timeout=4294967295, poll=0, alerted=0xbff5e23c) + 56 at handles.c:1476 [opt]
frame #7: 0x0031eb5f mono`wapi_WaitForMultipleObjectsEx(numobjects=<unavailable>, handles=<unavailable>, waitall=<unavailable>, timeout=<unavailable>, alertable=<unavailable>) + 1775 at wait.c:620 [opt]
frame #8: 0x002673d4 mono`mono_thread_manage [inlined] wait_for_tids_or_state_change(timeout=4294967295) + 82 at threads.c:3053 [opt]
frame #9: 0x00267382 mono`mono_thread_manage + 322 at threads.c:3258 [opt]
frame #10: 0x00138dc7 mono`mono_main(argc=<unavailable>, argv=<unavailable>) + 8855 at driver.g.c:2187 [opt]
frame #11: 0x000a4141 mono`main [inlined] mono_main_with_options(argc=6, argc=6, argc=6, argv=0xbff5e944, argv=0xbff5e944, argv=0xbff5e944) + 33 at main.c:28 [opt]
frame #12: 0x000a4120 mono`main(argc=6, argv=0xbff5e944) + 1184 at main.c:177 [opt]
frame #13: 0x000a3c75 mono`start + 53
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.