[Mono-bugs] [Bug 36252][Maj] New - IDisposable handling buggy
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
3 Jan 2003 10:08:07 -0000
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 jpo234@netscape.net.
http://bugzilla.ximian.com/show_bug.cgi?id=36252
--- shadow/36252 Fri Jan 3 05:08:07 2003
+++ shadow/36252.tmp.21401 Fri Jan 3 05:08:07 2003
@@ -0,0 +1,76 @@
+Bug#: 36252
+Product: Mono/Runtime
+Version: unspecified
+OS: Red Hat 8.0
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: jpo234@netscape.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: IDisposable handling buggy
+
+Description of Problem:
+It seems that the Dispose method of an IDisposable object is not called
+when leaving a using() {} statement through an exception.
+
+Steps to reproduce the problem:
+1. Compile and run the following example program from "Thinking in C#":
+
+//:c05:UsingCleanup.cs
+using System;
+
+class UsingCleanup : IDisposable {
+ public static void Main(){
+ try{
+ UsingCleanup uc = new UsingCleanup();
+ using(uc){
+ throw new NotImplementedException();
+ }
+ }catch(NotImplementedException){
+ Console.WriteLine("Exception ignored");
+ }
+ Console.WriteLine("Leaving Main( )");
+ }
+
+ UsingCleanup(){
+ Console.WriteLine("Constructor called");
+ }
+
+ public void Dispose(){
+ Console.WriteLine("Dispose called");
+ }
+
+ ~UsingCleanup(){
+ Console.WriteLine("Destructor called");
+ }
+}///:~
+
+Actual Results:
+
+mono UsingCleanup.exe
+Constructor called
+Exception ignored
+Leaving Main( )
+Destructor called
+
+Expected Results: (this is what I get under MS .NET SDK)
+
+.\UsingCleanup
+Constructor called
+Dispose called
+Exception ignored
+Leaving Main( )
+Destructor called
+
+How often does this happen?
+always.
+
+Additional Information:
+none