[Mono-list] [patch] GetEntryAssembly bug

Tomi Pakarinen Tomi.Pakarinen@iki.fi
21 Aug 2002 20:09:31 +0300


--=-0PoRMIrfwG0bfWNi9erw
Content-Type: text/plain
Content-Transfer-Encoding: 7bit



 
This patch fixes assertion failure caused by multiple ExecuteAssembly
calls for same domain. Tests are also attached. 


  Tomi.


--=-0PoRMIrfwG0bfWNi9erw
Content-Disposition: attachment; filename=entry.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=entry.patch; charset=ISO-8859-1

Index: mono/metadata/object.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/mono/mono/metadata/object.c,v
retrieving revision 1.112
diff -u -r1.112 object.c
--- mono/metadata/object.c	21 Aug 2002 13:04:20 -0000	1.112
+++ mono/metadata/object.c	21 Aug 2002 16:49:44 -0000
@@ -626,8 +626,8 @@
 	pa [0] =3D args;
=20
 	domain =3D mono_object_domain (args);
-	g_assert (!domain->entry_assembly);
-	domain->entry_assembly =3D method->klass->image->assembly;
+	if (!domain->entry_assembly)
+		domain->entry_assembly =3D method->klass->image->assembly;
=20
 	/* FIXME: check signature of method */
 	if (method->signature->ret->type =3D=3D MONO_TYPE_I4) {

--=-0PoRMIrfwG0bfWNi9erw
Content-Disposition: attachment; filename=test2.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=test2.cs; charset=ISO-8859-1

using System;=0D
using System.Reflection;=0D
=0D
class TestiMain {=0D
=0D
	static int Main( string [] args )=0D
	{=0D
		System.Reflection.Assembly assembly;=0D
		System.AppDomain otherDomain =3D System.AppDomain.CreateDomain("OtherDoma=
in");=0D
		otherDomain.ExecuteAssembly("AssemblyInOtherDomain.exe");=0D
		otherDomain.ExecuteAssembly("AssemblyInOtherDomain2.exe");=0D
		otherDomain.ExecuteAssembly("AssemblyInOtherDomain3.exe");=0D
		System.AppDomain.CurrentDomain.ExecuteAssembly("AssemblyInOtherDomain.exe=
");=0D
		System.AppDomain.CurrentDomain.ExecuteAssembly("AssemblyInOtherDomain2.ex=
e");=0D
		System.AppDomain.CurrentDomain.ExecuteAssembly("AssemblyInOtherDomain3.ex=
e");=0D
		/**/=0D
		Console.WriteLine( "From domain :" + System.AppDomain.CurrentDomain.ToStr=
ing() );=0D
		assembly =3D System.Reflection.Assembly.LoadFrom("AssemblyInOtherDomain.e=
xe");=0D
		Console.WriteLine( "Assembly: " + assembly.ToString() );=0D
		/**/=0D
		assembly =3D System.Reflection.Assembly.GetEntryAssembly();=0D
		Console.WriteLine( assembly.GetType().ToString() );=0D
		Console.WriteLine( "GetEntryAssembly =3D " + assembly.ToString() );=0D
		return 0;=0D
	}=0D
}=0D
// Output using .NET sdk.=0D
/*=0D
From domain :Name: OtherDomain=0D
There are no context policies.=0D
=0D
GetEntryAssembly =3D AssemblyInOtherDomain, Version=3D0.0.0.0, Culture=3Dne=
utral, PublicKeyToken=3Dnull=0D
From domain :Name: OtherDomain=0D
There are no context policies.=0D
=0D
GetEntryAssembly =3D AssemblyInOtherDomain, Version=3D0.0.0.0, Culture=3Dne=
utral, PublicKeyToken=3Dnull=0D
From domain :Name: OtherDomain=0D
There are no context policies.=0D
=0D
GetEntryAssembly =3D AssemblyInOtherDomain, Version=3D0.0.0.0, Culture=3Dne=
utral, PublicKeyToken=3Dnull=0D
From domain :Name: test2.exe=0D
There are no context policies.=0D
=0D
GetEntryAssembly =3D test2, Version=3D0.0.0.0, Culture=3Dneutral, PublicKey=
Token=3Dnull=0D
From domain :Name: test2.exe=0D
There are no context policies.=0D
=0D
GetEntryAssembly =3D test2, Version=3D0.0.0.0, Culture=3Dneutral, PublicKey=
Token=3Dnull=0D
From domain :Name: test2.exe=0D
There are no context policies.=0D
=0D
GetEntryAssembly =3D test2, Version=3D0.0.0.0, Culture=3Dneutral, PublicKey=
Token=3Dnull=0D
From domain :Name: test2.exe=0D
There are no context policies.=0D
=0D
Assembly: AssemblyInOtherDomain, Version=3D0.0.0.0, Culture=3Dneutral, Publ=
icKeyToken=3Dnull=0D
System.Reflection.Assembly=0D
GetEntryAssembly =3D test2, Version=3D0.0.0.0, Culture=3Dneutral, PublicKey=
Token=3Dnull=0D
*/=0D
=0D

--=-0PoRMIrfwG0bfWNi9erw
Content-Disposition: attachment; filename=AssemblyInOtherDomain.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=AssemblyInOtherDomain.cs; charset=ISO-8859-1

using System;
using System.Reflection;

class TestiMain2 {

	static int Main( string [] args )
	{
		Console.WriteLine( "From domain :" + System.AppDomain.CurrentDomain.ToStr=
ing() );
		System.Reflection.Assembly assembly =3D System.Reflection.Assembly.GetEnt=
ryAssembly();
		Console.WriteLine( "GetEntryAssembly =3D " + assembly.ToString() );
		return 0;
	}
}

--=-0PoRMIrfwG0bfWNi9erw--