Skip to content

fix(inproc): remove options lock from the handler thread - #2252

Merged
jpnurmi merged 2 commits into
jpnurmi/ref/session-optionsfrom
jpnurmi/fix/inproc-options
Oct 28, 2026
Merged

jpnurmi merged 2 commits into
jpnurmi/ref/session-optionsfrom
jpnurmi/fix/inproc-options

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

sentry_close() holds g_options_lock while joining the handler thread, so a crash during sentry_close() deadlocked in the SENTRY_WITH_OPTIONS of process_ucontext_deferred().

Pass the handler thread a counted options reference as its start argument, released when the thread exits. In-handler fallbacks keep using SENTRY_WITH_OPTIONS.

Fixes: #2244

@jpnurmi
jpnurmi added this pull request to stack #2250 October 27, 2026 11:07

@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.

Stale Bugbot comment from a previous run.

Comment thread src/backends/sentry_backend_inproc.c Resolved
@jpnurmi
jpnurmi removed this pull request from stack #2250 October 27, 2026 11:30
@jpnurmi
jpnurmi force-pushed the jpnurmi/fix/inproc-options branch from 4dab40b to 4500337 Compare October 27, 2026 11:39
@jpnurmi
jpnurmi changed the base branch from jpnurmi/ref/session-options to jpnurmi/ref/envelope-options October 27, 2026 11:39
@jpnurmi
jpnurmi added this pull request to stack #2253 October 27, 2026 11:39

@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 3f3015b. Configure here.

Comment thread src/backends/sentry_backend_inproc.c Resolved
@jpnurmi
jpnurmi force-pushed the jpnurmi/fix/inproc-options branch from 3f3015b to 5cdee6c Compare October 27, 2026 14:34
@jpnurmi
jpnurmi removed this pull request from stack #2253 October 27, 2026 14:34
@jpnurmi
jpnurmi changed the base branch from jpnurmi/ref/envelope-options to jpnurmi/ref/session-options October 27, 2026 14:35
@jpnurmi
jpnurmi added this pull request to stack #2257 October 27, 2026 14:35
`sentry_close()` holds `g_options_lock` while joining the handler
thread, so a crash during `sentry_close()` deadlocked in the
`SENTRY_WITH_OPTIONS` of `process_ucontext_deferred()`.

Pass the handler thread a counted options reference as its start
argument, released when the thread exits. In-handler fallbacks keep
using `SENTRY_WITH_OPTIONS`.

Fixes: #2244
`startup_inproc_backend()` returned an error after
`install_signal_handlers()` failed but left the handler thread running
with the options of the failed `sentry_init()`. The next `sentry_init()`
kept that thread instead of starting one with its own options.
@jpnurmi
jpnurmi force-pushed the jpnurmi/fix/inproc-options branch from 5cdee6c to 2282203 Compare October 27, 2026 14:42
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.00000% with 17 lines in your changes missing coverage. Please review.
βœ… Project coverage is 75.68%. Comparing base (72c5d95) to head (2282203).

Additional details and impacted files
@@                       Coverage Diff                       @@
##           jpnurmi/ref/session-options    #2252      +/-   ##
===============================================================
+ Coverage                        75.44%   75.68%   +0.24%     
===============================================================
  Files                              103      103              
  Lines                            28266    28281      +15     
  Branches                          5194     5199       +5     
===============================================================
+ Hits                             21324    21405      +81     
+ Misses                            5596     5529      -67     
- Partials                          1346     1347       +1     
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi
jpnurmi merged commit a4c7507 into master Oct 28, 2026
70 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/fix/inproc-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.

Android: crash during sentry_close() on SDK re-init deadlocks (handler blocks in read(), close blocks in pthread_join)

3 participants