Repository navigation
fix: release zlib state when a gzip upload body is destroyed early - #180
Merged
jpnurmi merged 2 commits intoNov 19, 2026
Merged
Conversation
A transport stops reading the request body when a network write fails: WinHttpWriteData() fails on Windows, or curl_easy_perform() fails before the read callback has drained the body. GzipHTTPBodyStream is then destroyed while still operating or flushing its trailer. Its destructor only DCHECKed that the stream had finished, so a debug crashpad_handler crashed, and a release handler leaked the deflate state of every failed upload. The destructor now calls deflateEnd() in those states. deflateEnd() frees the state even for an unfinished stream and returns Z_DATA_ERROR to say output was discarded, which is expected here and not logged. Upstream: https://issues.chromium.org/issues/587029408
1 of 3 tasks
jpnurmi
reviewed
Nov 18, 2026
jpnurmi
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the PR!
I'll open the sentry-native submodule bump once this is merged.
We could actually already create the submodule bump PR to run these changes through sentry-native's test suite. It's fine to bump the submodule to a sha1 in your fork because the ref is also known by the getsentry repo now that the PR is open. 👍
jpnurmi
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For getsentry/sentry-native#2323. Upstream report: https://issues.chromium.org/issues/587029408
When a network write fails partway through an upload, the transport stops reading the body.
GzipHTTPBodyStreamis then destroyed while it is stillkOperatingorkInputEOF. Its destructor only DCHECKed that the stream had finished, so a debugcrashpad_handlercrashed (0x80000003on Windows), and a release handler leaked the deflate state of every failed upload.The destructor now calls
deflateEnd()in those two states.deflateEnd()frees the state even for an unfinished stream. It returnsZ_DATA_ERRORto say unfinished output was discarded, which is expected here, so only other results are logged.Why this can't free twice.
kFinishedandkErrorare reached only throughDone(), which has already calleddeflateEnd(), or through a faileddeflateInit2(), which leaves nothing to free.kUninitializednever initialized zlib.Testing. The same destructor change, built through sentry-native 0.17.5, passed 100 iterations each of an unread, partially read, unfinished-trailer, completed and input-error stream in a Windows x64 debug build, with no CRT leak reports. We also build it as a patch on sentry-native 0.17.5 in our CI on Windows, Linux and macOS.
The sentry-native submodule bump that runs this through its test suite: getsentry/sentry-native#2326