mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Regression in SharpCompress 0.41.0: archive iteration breaks if input stream throws in Flush() #769
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rleroux-regnology on GitHub (Jan 23, 2026).
Originally assigned to: @adamhathcock, @Copilot on GitHub.
Summary
Since SharpCompress 0.41.0, archive iteration silently breaks when the input stream throws in
Flush().Only the first entry is returned, then iteration stops without exception.
This can be reproduced using a simple wrapper stream around a
FileStream.Minimal reproduction
Test program:
Expected behavior
If the archive contains N entries,
count == N.Actual behavior (0.44.1)
count == 1Iteration stops after the first entry.
No exception is thrown.
Workaround
If
Flush()is implemented as a no-op:Then all entries are iterated correctly.
Why this is a problem
Flush()has no semantic meaning for read-only input streams and should not be required for reading archives.Any library stream that:
can silently break SharpCompress iteration.
This includes:
MultipartReaderStreamRegression info
Suspected cause
SharpCompress 0.41.0 introduced a call to
Stream.Flush()somewhere in the read / entry iteration pipeline.If
Flush()throws, the internal state becomes inconsistent and iteration stops early.Related issue
This looks closely related to #1150.
In #1150,
EntryStream.Dispose()started callingFlush()on internal decompression streams (Deflate/LZMA), which breaks valid streaming scenarios (non-seekable / forward-only streams). In my case, beyond the exception scenario discussed there, I now also observe a silent regression: iteration stops after the first entry.Both issues share the same underlying theme:
Flush()(or its side-effects) should not be required nor relied upon in a read-only streaming pipeline, especially for forward-only/non-seekable streams.@adamhathcock commented on GitHub (Jan 24, 2026):
Try https://www.nuget.org/packages/SharpCompress/0.45.0-beta.144 and I can do a real release of 0.44.3
The API is slightly different for this beta though
@rleroux-regnology commented on GitHub (Jan 25, 2026):
After testing, I've found that the reported issue no longer exists in version 0.45.0-beta.144. Thank you very much!
PS: I have another problem now, but I first need to find a minimal reproduction scenario. I'll probably open a new issue fairly soon.
@adamhathcock commented on GitHub (Jan 25, 2026):
No problem. Please report. Hopefully something different!