Bug 29953 - Mocking libraries that use Castle.Core cause SIGABRT when mocking generic methods
Summary: Mocking libraries that use Castle.Core cause SIGABRT when mocking generic met...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Remoting ()
Version: 5.4 (2017-06)
Hardware: PC Linux
: Normal normal
Target Milestone: 15.5
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-11 14:47 UTC by Rudis Muiznieks
Modified: 2017-11-10 05:55 UTC (History)
10 users (show)

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

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 Rudis Muiznieks 2015-05-11 14:47:23 UTC
I have tested using Moq and NSubstitute (both of which use Castle.Core). When mocking generic methods, Mono 4.x crashes with a SIGABRT. The same code runs fine under Mono 3.x.

To reproduce, use a Castle.Core mocking library such as Moq or NSubstitute to mock an interface's generic function, as in the following gist: https://gist.github.com/rudism/497970d4d189af9857c2

Result: The code compiles and runs as expected in Mono 3.x. In Mono 4.x, it compiles fine but running it produces the following crash report:

* Assertion at sgen-alloc.c:460, condition `*p == NULL' not met

Stacktrace:

at <unknown> <0xffffffff>
at Castle.Proxies.IMockMeProxy.HelloWorld<T> () <IL 0x00052, 0x00147>
at MoqTest.MainClass.Main (string[]) [0x00057] in /source/MoqTest/MoqTest/Program.cs:17
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00060, 0xffffffff>

Native stacktrace:

mono() [0x4b8d92]
/lib64/libpthread.so.0(+0xf130) [0x7f61b2640130]
/lib64/libc.so.6(gsignal+0x37) [0x7f61b208f5d7]
/lib64/libc.so.6(abort+0x148) [0x7f61b2090cc8]
mono() [0x634dc9]
mono() [0x63503c]
mono() [0x6351d3]
mono() [0x5f1876]
mono() [0x5f1efd]
mono(mono_string_new_size+0x41) [0x5b4391]
mono(mono_string_new_utf16+0x10) [0x5b4440]
mono() [0x5b44bb]
mono() [0x470971]
mono() [0x42726f]
mono() [0x42a47d]
mono() [0x42ae8b]
mono() [0x4b9ecd]
[0x4054e166]

Debug info from gdb:


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

Aborted

My mono 4 test machine on which I reproduced this error is running CentOS 7 with the following output from mono --version:

Mono JIT compiler version 4.0.1 (tarball Wed Apr 29 08:44:01 BST 2015)
Copyright (C) 2002-2014 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:            sgen
Comment 1 gsimard 2017-10-10 21:05:16 UTC
This problem seems to have resurfaced with the update of Mono version 5.4.0.201
Comment 2 Luke McNally 2017-10-18 10:42:42 UTC
This is a real problem for us. We've upgraded some of our solutions to produce .NETStandard libraries, which require mono 5.4 on the build machine. However, we're hitting this bug with existing solutions that run unit tests using Castle.Core via mono. I've tried installing mono 5.2 alongside 5.4, but this breaks the .NETStandard builds.

Any ideas when this will be fixed?
Comment 3 Jaim.Zuber 2017-10-18 14:52:09 UTC
I'm seeing the problem with 5.4.0.201 used by Xamarin version 15.4

It worked with the previous Xamarin release using Mono 5.2.
Comment 4 Jaim.Zuber 2017-10-18 21:28:26 UTC
FWIW we were able to get our Xamarin builds running again by using Mono 5.2.
Comment 5 Johann B 2017-10-30 06:32:45 UTC
This quite a big problem for us on Mac OS. We really need to get this fixed since we soon need to convert our projects to .Net Standard too since most plugins out there are moving to .Net Standard at a rapid pace.

Rolling back to Mono 5.2 worked, but we really need a fix for this.
Comment 6 pragma.mobilexp 2017-10-30 10:36:40 UTC
Same issue for our team.  All our unit tests that make use of Moq (and thus Castle.Core) are now failing on 15.4.  Downgrading to 15.3/Mono 5.2 is not an option for us as we need .NET Standard support provided by 15.4/Mono5.4.  Any feedback from Xamarin?
Comment 7 Ludovic Henry 2017-11-08 22:46:37 UTC
Could you please provide a repro case so we can run it locally? Thank you.
Comment 8 Jaim.Zuber 2017-11-09 13:26:33 UTC
We've verified Mono 5.4.1.6 fixes this for our Xamarin unit tests using Moq.
Comment 9 Ludovic Henry 2017-11-09 21:26:28 UTC
Marking as resolved per response in https://bugzilla.xamarin.com/show_bug.cgi?id=29953#c8. Please reopen if you can reproduce. Thank you!
Comment 10 Johann B 2017-11-10 05:55:51 UTC
Confirmed Mono 5.4.1.6 solved our Moq issues aswell. Thanks.