Bug 12412 - Runtime crash during appdomain unload w/ NSubstitute, NUnit
Summary: Runtime crash during appdomain unload w/ NSubstitute, NUnit
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: Other Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2013-05-27 13:16 UTC by Mathieu Fenniak
Modified: 2017-08-28 15:04 UTC (History)
3 users (show)

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

built test project w/ required dependencies (1.25 MB, application/x-gzip)
2013-05-27 13:16 UTC, Mathieu Fenniak
full execution output (15.30 KB, text/plain)
2013-05-27 13:17 UTC, Mathieu Fenniak

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:

Description Mathieu Fenniak 2013-05-27 13:16:42 UTC
Created attachment 4025 [details]
built test project w/ required dependencies

Description of Problem: Runtime crash occurs with a combination of factors: using NSubstitute (a unit-test mocking framework) to mock an interface with a generic "out" value, and running the resulting unit test under nunit-console.exe.

Steps to reproduce the problem:
1. Extract mono-nsubstitute-crash.tar.gz attachment
2. xbuild
3. mono NUnit.Runners.2.6.1/tools/nunit-console.exe bin/Debug/mono-nsubstitute-crash.dll

Actual Results:

((full output to be included in an attachment))

Debug info from gdb:

Mono support loaded.
[New LWP 29059]
[New LWP 29058]
[New LWP 29052]
[New LWP 29049]
[New LWP 29048]
[New LWP 29047]
[New LWP 29046]
[New LWP 29045]
[New LWP 29044]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f5828d26d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
  Id   Target Id         Frame 
  10   Thread 0x7f5827a3e700 (LWP 29044) "mono" 0x00007f5828d26d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
  9    Thread 0x7f582723d700 (LWP 29045) "mono" 0x00007f5828d26d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
  8    Thread 0x7f5826a3c700 (LWP 29046) "mono" 0x00007f5828d26d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
  7    Thread 0x7f58259d9700 (LWP 29047) "mono" 0x00007f5828d28fd0 in sem_wait () from /lib/x86_64-linux-gnu/libpthread.so.0
  6    Thread 0x7f58253c4700 (LWP 29048) "mono" 0x00007f5828d2a04d in accept () from /lib/x86_64-linux-gnu/libpthread.so.0
  5    Thread 0x7f582517c700 (LWP 29049) "mono" 0x00007f5828d2a52d in nanosleep () from /lib/x86_64-linux-gnu/libpthread.so.0
  4    Thread 0x7f5824f7b700 (LWP 29052) "mono" 0x00007f5828d270fe in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
  3    Thread 0x7f5824a16700 (LWP 29058) "mono" 0x00007f5828d26d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
  2    Thread 0x7f5824811700 (LWP 29059) "mono" 0x00007f5828d2a88d in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
* 1    Thread 0x7f5829841740 (LWP 29043) "mono" 0x00007f5828d26d84 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0

... snip threads; see attachment ...

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.

Expected Results:

No crash after invoking the process.

How often does this happen? 

Every time.

Additional Information:

mono build is current GitHub HEAD as-of testing
$ mono --version
Mono JIT compiler version 3.0.12 (master/eda8f94 Mon May 27 10:10:56 MDT 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)

$ uname -a
Linux mfenniak-UX32VD 3.7.0-7-generic #15-Ubuntu SMP Sat Dec 15 16:34:25 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Was unable to reproduce this issue in a more minimal test-case.
Comment 1 Mathieu Fenniak 2013-05-27 13:17:16 UTC
Created attachment 4026 [details]
full execution output

Attaching full execution output.
Comment 2 Zoltan Varga 2013-05-28 12:15:45 UTC
Fixed in master. Thanks for the testcase.
Comment 3 Mathieu Fenniak 2013-05-28 12:51:15 UTC
Verified fix in master (8f1ba93b).  Thanks, that's an incredible turn-around time! :-)