[Mono-bugs] [Bug 67862][Wis] New - unloading appdomains crashes

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 8 Oct 2004 14:23:03 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ddulai@bloomberg.net.

http://bugzilla.ximian.com/show_bug.cgi?id=67862

--- shadow/67862	2004-10-08 14:23:03.000000000 -0400
+++ shadow/67862.tmp.2372	2004-10-08 14:23:03.000000000 -0400
@@ -0,0 +1,145 @@
+Bug#: 67862
+Product: Mono: Runtime
+Version: unspecified
+OS: All
+OS Details: linux or windows
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ddulai@bloomberg.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: unloading appdomains crashes
+
+this is how to reproduce the bug:
+
+% cat foo.cs
+using System;
+namespace TST {
+    public class Foo
+    {
+        public Foo() {
+            Console.WriteLine("Foo domain is {0}",
+                              AppDomain.CurrentDomain.FriendlyName);
+        }
+        static void Main(string[] args) {
+            // nothing
+        }
+    }
+}
+
+% cat loader2.cs 
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Runtime.Remoting;
+
+namespace TST {
+    [Serializable]
+    public class AppLoader : MarshalByRefObject
+    {
+        ObjectHandle _o;
+
+        public AppLoader() {
+            Console.WriteLine("domain is {0}",
+                              AppDomain.CurrentDomain.FriendlyName);
+
+            string ass = "foo.exe";
+            string name = "TST.Foo";
+
+            _o = AppDomain.CurrentDomain.CreateInstanceFrom(ass, name);
+
+            PrintDomains();
+        }
+
+        static void PrintDomains() {
+            Console.WriteLine("\nList of assemblies loaded " +
+                              "in current appdomain {0}:",
+                              AppDomain.CurrentDomain.FriendlyName);
+            foreach (Assembly assem in 
+AppDomain.CurrentDomain.GetAssemblies())
+                Console.WriteLine(assem.ToString());
+        }
+
+        static void Main(string[] args) {
+            AppDomain ad = AppDomain.CreateDomain("DOMAIN1");
+            AppLoader loader =
+                (AppLoader)ad.CreateInstanceFromAndUnwrap("loader2.exe",
+                                                          "TST.AppLoader");
+
+            PrintDomains();
+
+            loader = null;
+
+            AppDomain.Unload(ad);
+            ad = null;
+            Console.WriteLine("UNLOAD");
+
+            PrintDomains();
+        }
+    }
+}
+
+
+% csc  /t:exe /out:foo.exe  /debug  foo.cs  /define:DEBUG
+% csc  /t:exe /out:loader2.exe  /debug loader2.cs  /define:DEBUG
+
+this is with mono 1.0.2, on linux (see below for windows):
+
+% mono loader2.exe
+domain is DOMAIN1
+Foo domain is DOMAIN1
+
+List of assemblies loaded in current appdomain DOMAIN1:
+loader2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+Mono.CSharp.Debugger, Version=1.0.5000.0, Culture=neutral, 
+PublicKeyToken=0738eb9f132ed756
+foo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+__MetadataTypes, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+mscorlib, Version=1.0.5000.0, Culture=neutral, 
+PublicKeyToken=b77a5c561934e089
+
+List of assemblies loaded in current appdomain loader2.exe:
+loader2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+mscorlib, Version=1.0.5000.0, Culture=neutral, 
+PublicKeyToken=b77a5c561934e089
+
+** (loader2.exe:28798): WARNING **: : unref on 1041 called when ref was 
+already 0
+removing assembly 0x8105130
+removing assembly 0x82c31e0
+removing assembly 0x8390e38
+removing assembly 0x81d0de0
+removing assembly 0x8066a00
+UNLOAD
+zsh: 28797 segmentation fault (core dumped)  mono loader2.exe
+
+on windows with same version of mono, it just hangs mono.
+
+on windows w/ msft .net:
+
+% ./loader2.exe
+domain is DOMAIN1
+Foo domain is DOMAIN1
+
+List of assemblies loaded in current appdomain DOMAIN1:
+mscorlib, Version=1.0.5000.0, Culture=neutral, 
+PublicKeyToken=b77a5c561934e089
+loader2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+foo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+
+List of assemblies loaded in current appdomain loader2.exe:
+mscorlib, Version=1.0.5000.0, Culture=neutral, 
+PublicKeyToken=b77a5c561934e089
+loader2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+UNLOAD
+
+List of assemblies loaded in current appdomain loader2.exe:
+mscorlib, Version=1.0.5000.0, Culture=neutral, 
+PublicKeyToken=b77a5c561934e089
+loader2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null