Skip to content

Merge branch 'master' into ivana/recursive-guard-in-batcher

261ef0b
Select commit
Loading
Failed to load commit list.
Merged

fix(logging): Fix deadlock in log batcher #5684

Merge branch 'master' into ivana/recursive-guard-in-batcher
261ef0b
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed Mar 17, 2026 in 1m 59s

1 issue

find-bugs: Found 1 issue (1 medium)

Medium

flush() clobbers re-entrancy guard without checking existing state - `sentry_sdk/_batcher.py:117-122`

The flush() method unconditionally sets _active.flag = True and resets it to False in the finally block, without first checking if the flag was already set. If flush() is called while another method (like add()) has already set the flag on the same thread, the finally block will incorrectly clear the flag, defeating the re-entrancy protection for the remaining code in the outer method. This could allow a subsequent re-entrant add() call to pass the guard check when it should be blocked.

Also found at:

  • sentry_sdk/_span_batcher.py:65-66

Duration: 1m 57s · Tokens: 87.9k in / 5.2k out · Cost: $0.24 (+extraction: $0.01, +merge: $0.00)

Annotations

Check warning on line 122 in sentry_sdk/_batcher.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

flush() clobbers re-entrancy guard without checking existing state

The `flush()` method unconditionally sets `_active.flag = True` and resets it to `False` in the finally block, without first checking if the flag was already set. If `flush()` is called while another method (like `add()`) has already set the flag on the same thread, the finally block will incorrectly clear the flag, defeating the re-entrancy protection for the remaining code in the outer method. This could allow a subsequent re-entrant `add()` call to pass the guard check when it should be blocked.

Check warning on line 66 in sentry_sdk/_span_batcher.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

[MHU-N43] flush() clobbers re-entrancy guard without checking existing state (additional location)

The `flush()` method unconditionally sets `_active.flag = True` and resets it to `False` in the finally block, without first checking if the flag was already set. If `flush()` is called while another method (like `add()`) has already set the flag on the same thread, the finally block will incorrectly clear the flag, defeating the re-entrancy protection for the remaining code in the outer method. This could allow a subsequent re-entrant `add()` call to pass the guard check when it should be blocked.