Bug 12839 - NUnit dies with "Assertion at metadata.c:2558" just moments before finishing test run (maybe during AppDomain unload).
Summary: NUnit dies with "Assertion at metadata.c:2558" just moments before finishing ...
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2013-06-23 18:07 UTC by Pablo Ruiz García
Modified: 2017-08-28 15:04 UTC (History)
4 users (show)

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

Code demostrating the issue. (305.41 KB, application/octet-stream)
2013-06-23 18:07 UTC, Pablo Ruiz García

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 Pablo Ruiz García 2013-06-23 18:07:30 UTC
Created attachment 4182 [details]
Code demostrating the issue.


After upgrading to mono 3.0.12 (from 3.0.7) most of our unit tests crash near the end of the test run. It is reproducible with unit tests using NUnit and Gallio/MbUnit, each one with their provided console test runners.

After inspecting it a bit, I have created an small tests case which just creates a mock (using Rhino.Mocks):

using System;
using System.Collections.Generic;
using NUnit.Framework;
using Rhino.Mocks;

namespace Tests
        public interface IServiceLocator
            TService GetInstance<TService>();

        public class SampleTests
                protected static IServiceLocator _svcLocatorMock = null;

                public static void Main()
                        // Common infresructure mocks..
                        _svcLocatorMock = MockRepository.GenerateStub<IServiceLocator>();

                        var list = new List<string>();

This code when executed like: gmcs -target:library -out:test.dll -reference:Rhino.Mocks.dll -reference:nunit.framework.dll test.cs  && mono nunit-console.exe test.dll

Whill crash as follows:

NUnit-Console version
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
   OS Version: Unix
  CLR Version: 2.0.50727.1433 ( Mono 3.5 ( 3.0.12 (tarball Thu Jun 20 19:25:24 UTC 2013) ) )

ProcessModel: Default    DomainUsage: Single
Execution Runtime: mono-3.5
Tests run: 1, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.116321 seconds
  Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

* Assertion at metadata.c:2558, condition `method->declaring->klass->image == image || (method->context.class_inst && ginst_in_image (method->context.class_inst, image)) || (method->context.method_inst && ginst_in_image (method->context.method_inst, image)) || (((MonoMethod*)method)->signature && signature_in_image (mono_method_signature ((MonoMethod*)method), image))' not met


Native stacktrace:

        mono [0x80f9bbd]
        /lib/libc.so.6(gsignal+0x50) [0x138e00]
        /lib/libc.so.6(abort+0x101) [0x13a711]
        mono [0x8264862]
        mono [0x82648a7]
        mono [0x81a6bd7]
        mono [0x8261fa2]
        mono [0x81a6c5d]
        mono [0x818074f]
        mono [0x814fd68]
        mono(mono_domain_free+0x1f2) [0x81ea5c2]
        mono [0x81e55c9]
        mono [0x823e95e]
        mono [0x825002e]
        mono [0x825d5a5]
        /lib/libpthread.so.0 [0x880912]
        /lib/libc.so.6(clone+0x5e) [0x1e55de]

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.
Comment 1 Pablo Ruiz García 2013-06-23 18:18:13 UTC
I have just tested it with mono-3.0.10 and it doesnt reproduce. So it must have been some change on 3.0.11~3.0.12.

Hope it helps.
Comment 2 Pablo Ruiz García 2013-06-23 19:36:52 UTC
After applying ac8695db9fe1eeccf579964af5a4b8acd7deeceb from trunk (bug 12786), the problem seems to be fixed.