Skip to content

crashpad_handler DCHECKs (debug) and leaks zlib state (release) when a crash-report upload fails partway #2323

Closed

Description

@bionicbeagle

Description

When a network write fails partway through a crash-report upload, GzipHTTPBodyStream (external/crashpad/util/net/http_body_gzip.cc) is destroyed before the stream finishes. Its destructor only DCHECKs that the stream finished, so:

  • in a debug build, crashpad_handler hits the DCHECK (0x80000003 breakpoint on Windows)
  • in a release build, the zlib deflate state is never freed, roughly 256 KB per failed upload

The code is upstream Crashpad and is unchanged on the getsentry branch of getsentry/crashpad. Upstream report, with the full analysis and a unit-test repro: https://issues.chromium.org/issues/587029408

Proposed fix: call deflateEnd() in the destructor when the stream is still operating, and ignore the expected Z_DATA_ERROR:

GzipHTTPBodyStream::~GzipHTTPBodyStream() {
  // A failed or cancelled upload may destroy the body before reaching EOF.
  if (state_ == State::kOperating || state_ == State::kInputEOF) {
    int zr = deflateEnd(z_stream_.get());
    if (zr != Z_OK && zr != Z_DATA_ERROR) {
      LOG(ERROR) << "deflateEnd: " << ZlibErrorString(zr);
    }
  }
}

We carry this as a local patch on 0.17.5. It would be good to have it in getsentry/crashpad, whether picked up from upstream or applied directly, so SDK users get it without patching.

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

The handler fails while uploading a report it already captured, not while capturing the crash.

Environment

  • OS: Windows 11, 64-bit. The libcurl transport (Linux, macOS) stops reading the body the same way, so those platforms should be affected too
  • Compiler: MSVC 14.51 toolset (Visual Studio 2026)
  • CMake version and config: sentry-native 0.17.5, SENTRY_BACKEND=crashpad, Debug for the DCHECK, Release for the leak

Steps To Reproduce

  1. Start the crashpad backend with gzip uploads enabled (Crashpad's default)
  2. Capture a crash so the handler uploads a report
  3. Make the upload fail after the request has started, e.g. by dropping the connection mid-body
  4. In a debug build the handler hits the DCHECK in ~GzipHTTPBodyStream(). In a release build the deflate state is leaked

The upstream report has two unit tests that reproduce it directly against GzipHTTPBodyStream.

Activity

  1. linear-code commented on Nov 18, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 18, 2026
  3. added
    Bugsomething isn't working as it should
    Nativeplatform label
    on Nov 18, 2026
  4. jpnurmi commented on Nov 18, 2026

    @jpnurmi
    Collaborator

    Hi @bionicbeagle, thanks for the detailed report. Would you like to open a fix PR at https://github.com/getsentry/crashpad/pulls and a submodule bump PR here in sentry-native? 🙏

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 18, 2026
  6. bionicbeagle commented on Nov 18, 2026

    @bionicbeagle
    ContributorAuthor

    Sure, opened getsentry/crashpad#180 with the fix and tests. I'll follow up with the submodule bump here once it's merged.

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 18, 2026
  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugsomething isn't working as it shouldNativeplatform label

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions