Bug 14032 - Closing GZipStream raises ObjectDisposedException
Summary: Closing GZipStream raises ObjectDisposedException
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-08-16 09:57 UTC by Matthew Gerber
Modified: 2013-11-11 11:14 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Test case. (387 bytes, text/x-csharp)
2013-08-16 09:58 UTC, Matthew Gerber

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:

Description Matthew Gerber 2013-08-16 09:57:28 UTC
When using a GZipStream as shown in the attachment, calling Close() on the stream raises an ObjectDisposedException. It looks like it's disposing the underlying FileStream and then attempting to write some data to the disposed stream.
Comment 1 Matthew Gerber 2013-08-16 09:58:06 UTC
Created attachment 4647 [details]
Test case.
Comment 2 Matthew Gerber 2013-08-16 09:59:47 UTC
I should have mentioned that I'm running Mono compiled from Git on Xubuntu 12.04.
Comment 3 Matthew Gerber 2013-08-16 11:32:07 UTC
Looks like DeflateStream.Dispose is closing the base stream and then calling DeflateStreamNative.Dispose, which eventually calls a Write operation on the closed base stream. My workaround for now is to construct the GZipStream using the three-parameter constructor, passing "true" as the last parameter to leave the base stream open. Then close the GZipStream and then close the base stream manually. I'm not exactly sure what the proper fix is though.
Comment 4 Marek Safar 2013-08-16 17:21:56 UTC
Fixed in master