Skip to content

fix

ac5c6d1
Select commit
Loading
Failed to load commit list.
Merged

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

fix
ac5c6d1
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed Mar 17, 2026 in 1m 46s

1 issue

find-bugs: Found 1 issue (1 medium)

Medium

flush() missing re-entry guard check - `sentry_sdk/_batcher.py:117-122`

The flush() method sets _active.flag = True without first checking if it's already set. Unlike add() which guards with if getattr(self._active, "flag", False): return None, flush() unconditionally sets the flag and proceeds. If _flush() triggers a GC warning that routes back through the logging integration to flush() (instead of add()), the nested flush() will execute, and its finally block will set _active.flag = False prematurely, leaving subsequent re-entrant calls unprotected.


Duration: 1m 46s · Tokens: 202.4k in / 7.7k out · Cost: $0.42 (+extraction: $0.01)

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() missing re-entry guard check

The `flush()` method sets `_active.flag = True` without first checking if it's already set. Unlike `add()` which guards with `if getattr(self._active, "flag", False): return None`, `flush()` unconditionally sets the flag and proceeds. If `_flush()` triggers a GC warning that routes back through the logging integration to `flush()` (instead of `add()`), the nested `flush()` will execute, and its finally block will set `_active.flag = False` prematurely, leaving subsequent re-entrant calls unprotected.