Repository navigation
ref(scope): Let global scope flush itself - #2167
Conversation
3fdc2e5 to
c643461
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2167 +/- ##
==========================================
+ Coverage 75.48% 75.55% +0.07%
==========================================
Files 103 103
Lines 28089 28171 +82
Branches 5150 5159 +9
==========================================
+ Hits 21202 21286 +84
+ Misses 5545 5530 -15
- Partials 1342 1355 +13 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c441a85. Configure here.
37d1de1 to
1a7ddcf
Compare
1a7ddcf to
767513a
Compare
limbonaut
left a comment
There was a problem hiding this comment.
This was flagged during a scan:
Running flush_func under observers_lock can deadlock with sentry_close(). With Crashpad’s external reporter enabled on macOS or Windows, the flush calls sentry__envelope_new(), which acquires the options lock. Concurrent shutdown holds that lock and waits for observers_lock, so both threads block indefinitely. I reproduced this lock ordering with an isolated backend hook. Using sentry__envelope_new_with_dsn(options->dsn) in flush_external_crash_report() avoids the nested options-lock acquisition and lets the reproduction complete.
Suggested fix:
--- a/src/backends/sentry_backend_crashpad.cpp
+++ b/src/backends/sentry_backend_crashpad.cpp
@@ -320,7 +320,7 @@ flush_external_crash_report(crashpad_state_t *state,
const base::FilePath &external_report_path, const sentry_options_t *options,
const sentry_uuid_t *crash_event_id)
{
- sentry_envelope_t *envelope = sentry__envelope_new();
+ sentry_envelope_t *envelope = sentry__envelope_new_with_dsn(options->dsn);
if (!envelope) {
return;
}
limbonaut
left a comment
There was a problem hiding this comment.
Nice improvement. Scope setters know better which changes require persistence, so the caller does not have to pick the correct macro (a potential failure point). And it helps batching. Take a look at the flagged issue above before merging.
A step toward letting users acquire access to the global scope. One of the blocker problems for direct global scope access was that it would bypass flushing, which was previously controlled by the internal WITH_SCOPE wrapper macro. This PR solves the problem by assigning a flush_func to the global scope, and letting it flush itself whenever appropriate.
712e704 to
822310f
Compare

A significant step toward letting users acquire direct access to the global scope.
One of the blocker problems for direct global scope access that came up in #2160 was that it would bypass flushing, which was previously controlled by the internal
WITH_SCOPEwrapper macro. This PR solves the problem by assigning aflush_functo let the global scope flush itself after mutations.