Skip to content

fix(win): buffer attachment updates - #174

Merged
jpnurmi merged 3 commits into
getsentryfrom
jpnurmi/fix/crashpad-pipe
Oct 12, 2026
Merged

jpnurmi merged 3 commits into
getsentryfrom
jpnurmi/fix/crashpad-pipe

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

An attachment IPC update waits for acknowledgment, which is correctly sent before the request's disk write. However, when the handler proceeds to the disk write, it keeps the instance busy and therefore indirectly blocks any potential other incoming updates during the I/O. In essence, during heavy congestion, later IPC updates can block on disk I/O from earlier requests when both instances are busy.

Avoid that by buffering attachment IPC updates before acknowledging them. Writes replace pending content and appends extend it, and flush the buffers when appropriate.

Note: RegisterHandlers is made public on Windows to allow sentry-native's backend reinstall to preserve the attachment IPC update buffer.

Ref: getsentry/sentry-native#2182

Expose `CrashpadClient::RegisterHandlers()` so sentry-native can restore
the Windows crash handlers after another runtime replaces them, such as
Unity installing its own handlers.

Without access to this method, `sentry_reinstall_backend()` shuts down
and starts the backend again. This launches another handler process and
reloads breadcrumbs into the existing ring, duplicating them. Exposing
the registration method lets the SDK preserve its client, handler
process, IPC pipe, and breadcrumb state.

Ref: getsentry/sentry-native#2182
The attachment IPC round trip waits for acknowledgment, which is sent
before the request's disk write. The write then continues on the pipe
service thread, keeping that pipe instance occupied. Later breadcrumb
or scope updates can block on disk I/O from earlier requests when both
instances are busy. Acknowledging before storing also allows consecutive
updates to reach the delegate out of order, so a truncating write can
erase a later append.

Buffer each writable file under `attachments_lock_` before acknowledging
its update. Writes replace pending content and appends extend it. Flush
the buffers while the client is suspended, before resolving attachments
or reading the external crash reporter envelope. Both crash dumps and
`DumpWithoutCrash` use this path.

Append-only updates extend preloaded file contents, while truncation
keeps breadcrumb buffers bounded as the ring rotates. The handler kept
across sentry-native backend reinstall preserves these pending updates.

Ref: getsentry/sentry-native#2182

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e4f0317. Configure here.

Comment thread handler/win/crash_report_exception_handler.cc
The external crash reporter path deletes the database report, so the
envelope is the only artifact. Flush again under the envelope lock so an
update stored during the dump is included. The map is empty after the
first flush, so only late arrivals are written.
@jpnurmi
jpnurmi merged commit 493151b into getsentry Oct 12, 2026
26 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/fix/crashpad-pipe branch October 12, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants