Skip to content

ref: remove options lock from sentry_envelope - #2248

Merged
jpnurmi merged 1 commit into
masterfrom
jpnurmi/ref/envelope-options
Oct 28, 2026
Merged

jpnurmi merged 1 commit into
masterfrom
jpnurmi/ref/envelope-options

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Taking g_options_lock via SENTRY_WITH_OPTIONS deep in sentry__envelope_new() was a footgun. Creating envelopes from any other thread during sentry_close() would deadlock.

Just pass the options - most production code callers already have a reference, anyway. NULL options, which is mostly needed in tests, create an envelope without a DSN header. sentry__envelope_new_with_dsn() stays for the batcher, which holds only a DSN reference.

Partial fix to: #2244

@jpnurmi
jpnurmi added this pull request to stack #2250 October 26, 2026 16:26
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.65%. Comparing base (2794b86) to head (06c3572).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2248      +/-   ##
==========================================
+ Coverage   75.57%   75.65%   +0.08%     
==========================================
  Files         103      103              
  Lines       28266    28255      -11     
  Branches     5180     5180              
==========================================
+ Hits        21361    21376      +15     
+ Misses       5563     5533      -30     
- Partials     1342     1346       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/envelope-options branch from 4b0656c to 54169f4 Compare October 27, 2026 11:30
@jpnurmi
jpnurmi removed this pull request from stack #2250 October 27, 2026 11:30
@jpnurmi
jpnurmi changed the base branch from v1 to master October 27, 2026 11:30
@jpnurmi
jpnurmi added this pull request to stack #2253 October 27, 2026 11:39
@jpnurmi
jpnurmi removed this pull request from stack #2253 October 27, 2026 14:34
@jpnurmi
jpnurmi added this pull request to stack #2257 October 27, 2026 14:35
Taking `g_options_lock` in `sentry__envelope_new()` and
`sentry__envelope_add_event()` was a footgun for threads that a lock
holder waits on, such as the inproc handler thread that
`sentry_close()` joins while holding the lock.

Take the DSN and `traces_sample_rate` from the caller's options
instead. `NULL` options mean no DSN header and a `traces_sample_rate`
of 0. `sentry__envelope_new_with_dsn()` stays for the batcher, which
holds only a DSN reference.

Ref: #2244
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/envelope-options branch from 54169f4 to 06c3572 Compare October 27, 2026 14:41
@jpnurmi
jpnurmi merged commit 69f900c into master Oct 28, 2026
70 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/ref/envelope-options branch October 28, 2026 08:18
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.

3 participants