Problem
StackOverflowError in SentryLogcatAdapter (SDK-CRASHES-JAVA-3T3H, 163 occurrences, 4 users, seen up to 8.45.0).
When the Sentry Android Gradle Plugin's logcat instrumentation is enabled, android.util.Log.* calls in the app's own code are rewritten to SentryLogcatAdapter.*. Infinite recursion occurs when code that runs while a Logcat breadcrumb or log is being captured itself calls a rewritten Log.*:
SentryLogcatAdapter.w() → addAsBreadcrumb() / addAsLog() → app beforeBreadcrumb / beforeSendLog callback → rewritten Log.w() → SentryLogcatAdapter.w() → …
Note: this is not caused by the plugin instrumenting the SDK — io.sentry.* classes are excluded. The re-entry comes from app code reachable during breadcrumb/log processing, so it can only be broken at runtime in the SDK.
Fix
A single thread-local re-entrancy guard (isCapturing) shared across both addAsBreadcrumb() and addAsLog(). Any re-entrant capture on the same thread is a no-op; the real Log.* call is left untouched so logcat output is preserved. Covered by regression tests for both the breadcrumb and logs paths.
Links
Problem
StackOverflowErrorinSentryLogcatAdapter(SDK-CRASHES-JAVA-3T3H, 163 occurrences, 4 users, seen up to 8.45.0).When the Sentry Android Gradle Plugin's logcat instrumentation is enabled,
android.util.Log.*calls in the app's own code are rewritten toSentryLogcatAdapter.*. Infinite recursion occurs when code that runs while a Logcat breadcrumb or log is being captured itself calls a rewrittenLog.*:SentryLogcatAdapter.w()→addAsBreadcrumb()/addAsLog()→ appbeforeBreadcrumb/beforeSendLogcallback → rewrittenLog.w()→SentryLogcatAdapter.w()→ …Note: this is not caused by the plugin instrumenting the SDK —
io.sentry.*classes are excluded. The re-entry comes from app code reachable during breadcrumb/log processing, so it can only be broken at runtime in the SDK.Fix
A single thread-local re-entrancy guard (
isCapturing) shared across bothaddAsBreadcrumb()andaddAsLog(). Any re-entrant capture on the same thread is a no-op; the realLog.*call is left untouched so logcat output is preserved. Covered by regression tests for both the breadcrumb and logs paths.Links