Bug 17805 - * Assertion at mini.c:4157, condition `code' not met
Summary: * Assertion at mini.c:4157, condition `code' not met
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-02-16 18:54 UTC by Alexandre Faria
Modified: 2014-02-21 09:45 UTC (History)
4 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 Alexandre Faria 2014-02-16 18:54:55 UTC
Mono crashes under several circumstances with this error running integration tests, but the stack trace variates.

Mono JIT compiler version 3.2.7 (master/50685c9 Dom Fev 16 14:32:53 WET 2014)
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:          yes(3.4svn-mono-mono/e656cac)
	GC:            sgen


* Assertion at mini.c:4157, condition `code' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff>
  at System.Reflection.MonoCMethod.InternalInvoke (object,object[]) [0x00002] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:537
  at System.Reflection.MonoCMethod.DoInvoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000a5] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:528
  at System.Reflection.MonoCMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x0003d] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:500
  at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:114
  at System.Runtime.Serialization.ObjectRecord.LoadData (System.Runtime.Serialization.ObjectManager,System.Runtime.Serialization.ISurrogateSelector,System.Runtime.Serialization.StreamingContext) [0x000dd] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization/ObjectManager.cs:585
  at System.Runtime.Serialization.ObjectManager.DoFixups () [0x00074] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization/ObjectManager.cs:85
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject (System.IO.BinaryReader) [0x0000f] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs:141
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph (System.Runtime.Serialization.Formatters.Binary.BinaryElement,System.IO.BinaryReader,bool,object&,System.Runtime.Remoting.Messaging.Header[]&) [0x0004d] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs:107
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream,System.Runtime.Remoting.Messaging.HeaderHandler) [0x0007a] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:177
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream) [0x00000] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:134
  at System.Runtime.Remoting.RemotingServices.DeserializeCallData (byte[]) [0x0000f] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs:794
  at (wrapper xdomain-dispatch) System.AppDomain.CreateInstanceAndUnwrap (object,byte[]&,byte[]&,string,string,bool) <IL 0x000a4, 0xffffffff>
  at (wrapper xdomain-invoke) System.AppDomain.CreateInstanceAndUnwrap (string,string,bool,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[]) <0xffffffff>
  at (wrapper remoting-invoke-with-check) System.AppDomain.CreateInstanceAndUnwrap (string,string,bool,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[]) <0xffffffff>


* Assertion at mini.c:4157, condition `code' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at System.Runtime.Serialization.Formatters.Binary.CodeGenerator.GenerateMetadataTypeInternal (System.Type,System.Runtime.Serialization.StreamingContext) [0x0010c] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/CodeGenerator.cs:103
  at System.Runtime.Serialization.Formatters.Binary.CodeGenerator.GenerateMetadataType (System.Type,System.Runtime.Serialization.StreamingContext) [0x00010] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/CodeGenerator.cs:63
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.CreateMemberTypeMetadata (System.Type) [0x0000a] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:474
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.GetObjectData (object,System.Runtime.Serialization.Formatters.Binary.TypeMetadata&,object&) [0x001d9] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:458
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObject (System.IO.BinaryWriter,long,object) [0x00000] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:316
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance (System.IO.BinaryWriter,object,bool) [0x00062] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:303
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects (System.IO.BinaryWriter) [0x00005] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:281
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph (System.IO.BinaryWriter,object,System.Runtime.Remoting.Messaging.Header[]) [0x0001f] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:268
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream,object,System.Runtime.Remoting.Messaging.Header[]) [0x0005f] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:230
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream,object) [0x00000] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:209
  at System.Runtime.Remoting.Channels.CADSerializer.SerializeObject (object) [0x0000c] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs:322
  at System.AppDomain.GetMarshalledDomainObjRef () [0x00016] in /repository/repositories/mono/2014-02-16/mono/mcs/class/corlib/System/AppDomain.cs:1360
  at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <IL 0x0001c, 0xffffffff>
  at System.AppDomain.InvokeInDomain (System.AppDomain,System.Reflection.MethodInfo,object,object[]) <0x00097>
  at System.Runtime.Remoting.RemotingServices.GetDomainProxy (System.AppDomain) <0x0006b>
  at System.AppDomain.CreateDomain (string,System.Security.Policy.Evidence,System.AppDomainSetup) <0x0029b>
Comment 1 Zoltan Varga 2014-02-17 11:25:59 UTC
Could you create some kind of testcase which reproduces the problem ?
Comment 2 Alexandre Faria 2014-02-17 17:38:19 UTC
Its a bit hard, because its a testing framework that causes this after some thousands of tests are run. And the stackstrace differs.

I have returned to a test case that I used before, that tries to stress mono a bit, by creating and unloading AppDomains, it crashes around AppDomain number 2551/2552 with the same error, but stacktraces still vary.

Such a large number of AppDomains makes sense in the production context of this testing framework, so that might be the cause.

Here is the test case:
using System;

public class Example
{
  public static void Main()
  {
    for(int i=0; i<10000; i++)
    {
      System.Console.WriteLine("\n\nIteration " + i);
      AppDomain ad = AppDomain.CreateDomain("ChildDomain");
      AppDomain.Unload(ad);
    }
  }
}


Here is a stacktrace:
* Assertion at mini.c:4157, condition `code' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.AppDomain.createDomain (string,System.AppDomainSetup) <0xffffffff>
  at System.AppDomain.CreateDomain (string,System.Security.Policy.Evidence,System.AppDomainSetup) <0x00293>
  at System.AppDomain.CreateDomain (string) <0x00017>
  at Example.Main () <0x00053>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	mono() [0x4bac18]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0xfbb0) [0x7fab72199bb0]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7fab71df8f77]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7fab71dfc5e8]
	mono() [0x63c2c5]
	mono() [0x63c406]
	mono() [0x4216fd]
	mono() [0x4246d8]
	mono() [0x42688f]
	mono() [0x427802]
	mono(mono_runtime_invoke+0x3d) [0x5b904d]
	mono() [0x53b1a1]
	mono() [0x5a7d41]
	mono() [0x5a9af4]
	mono() [0x5a9c1c]
	[0x4022a743]

Here is another stacktrace:
* Assertion at mini.c:4157, condition `code' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at System.Runtime.Serialization.Formatters.Binary.CodeGenerator.GenerateMetadataTypeInternal (System.Type,System.Runtime.Serialization.StreamingContext) <0x00aa7>
  at System.Runtime.Serialization.Formatters.Binary.CodeGenerator.GenerateMetadataType (System.Type,System.Runtime.Serialization.StreamingContext) <0x0005b>
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.CreateMemberTypeMetadata (System.Type) <0x0004f>
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.GetObjectData (object,System.Runtime.Serialization.Formatters.Binary.TypeMetadata&,object&) <0x008b3>
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObject (System.IO.BinaryWriter,long,object) <0x00057>
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance (System.IO.BinaryWriter,object,bool) <0x0016f>
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects (System.IO.BinaryWriter) <0x00037>
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph (System.IO.BinaryWriter,object,System.Runtime.Remoting.Messaging.Header[]) <0x0005f>
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream,object,System.Runtime.Remoting.Messaging.Header[]) <0x0027b>
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream,object) <0x00027>
  at System.Runtime.Remoting.Channels.CADSerializer.SerializeObject (object) <0x000cb>
  at System.AppDomain.GetMarshalledDomainObjRef () <0x00027>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <0xffffffff>
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
  at System.AppDomain.InvokeInDomain (System.AppDomain,System.Reflection.MethodInfo,object,object[]) <0x00097>
  at System.Runtime.Remoting.RemotingServices.GetDomainProxy (System.AppDomain) <0x0006b>
  at System.AppDomain.CreateDomain (string,System.Security.Policy.Evidence,System.AppDomainSetup) <0x0029b>
  at System.AppDomain.CreateDomain (string) <0x00017>
  at Example.Main () <0x00053>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	mono() [0x4bac18]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0xfbb0) [0x7f41a808bbb0]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f41a7ceaf77]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7f41a7cee5e8]
	mono() [0x63c2c5]
	mono() [0x63c406]
	mono() [0x4216fd]
	mono() [0x4246d8]
	mono() [0x42688f]
	mono() [0x42739b]
	mono() [0x4bbceb]
	[0x4079b166]
Comment 3 Zoltan Varga 2014-02-20 17:52:25 UTC
Fixed by 426c784f500cbb0ca0ecca5d9c4d36bc2164d025. Sorry about that.
Comment 4 Alexandre Faria 2014-02-21 09:45:06 UTC
LLVM build is broken now, so I had to use the regular build.

But I was able to confirm the fix in the test case.
I'm going to execute in production, but that will take some hours.
If I find another I'll try to reproduce it first.

Thanks!