Bug 47432 - Cannot zip files over 2GB
Summary: Cannot zip files over 2GB
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: SharpZipLib ()
Version: 4.6.0 (C8)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-11-18 22:04 UTC by Felix Schlesinger
Modified: 2017-01-04 22:39 UTC (History)
2 users (show)

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

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:
Status:
RESOLVED FIXED

Description Felix Schlesinger 2016-11-18 22:04:21 UTC
The following code to create a zip archive with a single file fails when the file to zip is over 2GB in size:

using (var zip = ZipFile.Open(zipFn, ZipArchiveMode.Create))
    zip.CreateEntryFromFile(toZip, Path.GetFileName(toZip));

Using mono 4.6.0 running on CentOS 6 I get:

Unhandled Exception:
System.IO.IOException: Stream was too long.
  at System.IO.MemoryStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0009e] in <filename unknown>:0
  at SharpCompress.IO.NonDisposingStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00006] in <filename unknown>:0
  at System.IO.Compression.ZipArchiveEntryStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000] in <filename unknown>:0
  at System.IO.Stream.InternalCopyTo (System.IO.Stream destination, System.Int32 bufferSize) [0x0000c] in <filename unknown>:0
  at System.IO.Stream.CopyTo (System.IO.Stream destination) [0x00099] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.IO.Stream:CopyTo (System.IO.Stream)
  at System.IO.Compression.ZipFileExtensions.CreateEntryFromFile (System.IO.Compression.ZipArchive destination, System.String sourceFileName, System.String entryName, System.IO.Compression.CompressionLevel compressionLevel) [0x0005e] in <filename unknown>:0
  at System.IO.Compression.ZipFileExtensions.CreateEntryFromFile (System.IO.Compression.ZipArchive destination, System.String sourceFileName, System.String entryName) [0x00000] in <filename unknown>:0

Running the same code in windows directly in visual studio 2015 works correctly. Zipping files <2GB works on both VS and mono.

It appears that the memory stream mono is using is limited to 32bit / 2GB.
Comment 1 Marek Safar 2017-01-04 22:39:13 UTC
Fixed in master