https://bugzilla.novell.com/show_bug.cgi?id=357519


           Summary: IDisposable incorrectly implemented in streams
           Product: Mono: Class Libraries
           Version: 1.2.5
          Platform: Other
        OS/Version: Debian Woody
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]
         QAContact: [email protected]
          Found By: Customer


Description of Problem:

Mono doesn't handle dispose correctly in streams.


Unhandled Exception: System.ObjectDisposedException: The object was used after
being disposed.
  at System.IO.Compression.DeflateStream.FlushInternal (Boolean finish)
[0x00000]
  at System.IO.Compression.DeflateStream.Dispose (Boolean disposing) [0x00000]
  at System.IO.Stream.Close () [0x00000]
  at System.IO.Stream.Dispose () [0x00000]
  at (wrapper remoting-invoke-with-check) System.IO.Stream:Dispose ()
  at System.IO.Compression.GZipStream.Dispose (Boolean disposing) [0x00000]
  at System.IO.Stream.Close () [0x00000]
  at System.IO.BinaryWriter.Dispose (Boolean disposing) [0x00000]
  at System.IO.BinaryWriter.System.IDisposable.Dispose () [0x00000]
  at DictionaryBuilding.ProbDict.Merge.GeneralWriter.WriteAll () [0x00000]
  at DictionaryBuilding.ProbDict.EMAlgorithm.EM (Int32 steps) [0x00000]
  at DictionaryBuilding.DictionaryBuilding.Calculate () [0x00000]
  at DictionaryBuilding.Program.Main (System.String[] args) [0x00000]

Unhandled Exception: System.ObjectDisposedException: The object was used after
being disposed.
  at System.IO.Compression.DeflateStream.FlushInternal (Boolean finish)
[0x00000]
  at System.IO.Compression.DeflateStream.Dispose (Boolean disposing) [0x00000]
  at System.IO.Stream.Close () [0x00000]
  at System.IO.Stream.Dispose () [0x00000]
  at (wrapper remoting-invoke-with-check) System.IO.Stream:Dispose ()
  at System.IO.Compression.GZipStream.Dispose (Boolean disposing) [0x00000]
  at System.IO.Stream.Close () [0x00000]
  at System.IO.Stream.System.IDisposable.Dispose () [0x00000]
  at DictionaryBuilding.ProbDict.Merge.GeneralWriter.WriteAll () [0x00000]
  at DictionaryBuilding.ProbDict.EMAlgorithm.EM (Int32 steps) [0x00000]
  at DictionaryBuilding.DictionaryBuilding.Calculate () [0x00000]
  at DictionaryBuilding.Program.Main (System.String[] args) [0x00000]
*** glibc detected *** mono: double free or corruption (!prev): 0x08483100 ***

Source code:

using (Stream s1 = new BufferedStream(File.OpenWrite(filename))) 
            {
                using (GZipStream s = new GZipStream(s1,
CompressionMode.Compress))
                {
                    using (BinaryWriter bw = new BinaryWriter(s))
                    {
                        foreach (Wordpair wp in child.Iterate())
                        {
                            if (wp.P >= 0.0f)
                            {
                                bw.Write(wp.X);
                                bw.Write(wp.Y);
                                bw.Write(wp.P);
                            }
                        }
                        bw.Write(-1);
                        bw.Write(-1);
                        bw.Write(-1);
                        bw.Close();
                    }
                    s.Close();
                }
                s1.Close();
            }

Note that this code is perfectly legal in .NET!

Actual Results:
Crash

Expected Results:
No crash :-)

How often does this happen? 
Always

Additional Information:
Behavior of IDisposable is incorrect. This happens in almost all classes with
resources that are being managed. The solution is to implement the IDisposable
pattern as stated on microsoft.com correctly.

Greetings,
Stefan.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to