fix: crashpad scope flushing synchronization #1019
Merged
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.
This change cleans up a couple of issues in the current crashpad backend:
mpack
in the signal handler, which uses system malloc. This change configures mpack to usesentry_malloc
, which switches to the page-allocator inside the signal handler. Fixes Inconsistent allocator usage causing crashes #687.__sentry_event
outside the handler on Linux.crashpad_backend_flush_scope
and the signal handler), which could be called from two different threads. We can ensure that these two paths handle separate local events.__sentry_event
files if the scope flushing is triggered from a thread other than the signal handler thread, silently invalidating any changes to the event coming from thebefore_send
andon_crash
hooks. This is now fully synchronized in the following fashion:crashpad_backend_flush_scope
signals viastd::atomic<bool>
that a flush is in progressFirstChanceHandler
on any incoming signal (Linux) or unhandled exception (Windows). While we locked the signal handler on Linux, the Windows handler would be called twice if another thread also surfaces an exception. This is bad because the signal handler doesn't act like it will only be called once before it terminates. This adapts the code in the crashpad client to prevent second invocations to theFirstChanceHandler
. This adapts the proposed changes by: FirstChanceHandler execute once crashpad#95