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 completed Mar 17, 2026 in 2m 31s

2 issues

High

Re-entry guard flag not reset on early return, causing spans to be silently dropped - `sentry_sdk/_span_batcher.py:65-66`

When _ensure_thread() returns False or _flusher is None, the function returns at line 66 without entering the try/finally block. This leaves self._active.flag set to True, causing all subsequent calls to add() on the same thread to be silently dropped. Compare with the parent Batcher.add() in _batcher.py where the _ensure_thread() check is inside the try block to ensure the flag is always reset.

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
4 skills analyzed
Skill Findings Duration Cost
code-review 1 57.8s $0.22
find-bugs 1 1m 57s $0.23
skill-scanner 0 45.9s $0.16
security-review 0 34.3s $0.11

Duration: 4m 15s · Tokens: 420.8k in / 11.8k out · Cost: $0.75 (+extraction: $0.02, +fix_gate: $0.00, +dedup: $0.00, +merge: $0.00)