Repository navigation
fix(android): [Throwable Boundaries 2] Rethrow fatal errors at sentry-android-core boundaries - #6658
Draft
runningcode wants to merge 1 commit into
Draft
runningcode wants to merge 1 commit into
runningcode wants to merge 1 commit into
Conversation
The broad catches left in sentry-android-core guard Binder calls into system services, the app's own views and contexts, data parceled by other processes, files written by crashing processes, and the configuration callback. Call ExceptionUtils.rethrowIfFatal first in each of them, so OutOfMemoryError, StackOverflowError and LinkageError are no longer swallowed, and say why the catch is broad and what happens on failure. getProcessesInErrorState keeps swallowing OutOfMemoryError: unparceling its reply can fail to allocate without the app being out of memory (#2114). Sites whose failures are known are narrowed instead: the native envelope parsing in NativeEventCollector, the DeviceInfoUtil future in DefaultAndroidEventProcessor, the Build reads in getFamily and isEmulator, and the envelope item reads in TombstoneIntegration. The catch around the cached split APK info guarded nothing and is removed. SentryAndroid.init now documents what happens when the configuration handler throws. Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
This was referenced Nov 18, 2026
5 of 9 tasks
📲 Install BuildsAndroid
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (Throwable Boundaries)
📜 Description
This PR handles the 64 remaining swallowing
catch (Throwable)sites insentry-android-core, including the six sites #6564 left for this pass:ExceptionUtils.rethrowIfFatalfirst, with a comment saying why the catch is broad and what is lost when it fails. They guard:PackageManager,ActivityManager,ConnectivityManager,ProfilingManager, receiver registration,getExternalFilesDirs.draw(),getResources(), component callbacks.ApplicationStartInfo.PixelCopy,Bitmap.compress,Choreographer, frame metrics listeners,FileObserver.InternalSentrySdk, the ANR profiling thread, and theSentryAndroid.initconfiguration callback.NativeEventCollector:IOException,IllegalStateException(the JSON reader's unexpected token) andNumberFormatExceptionwhere they apply. Envelope item data usesException, whichSentryEnvelopeItem.getData()declares.TombstoneIntegrationenvelope item data:Exception, for the same reason.DefaultAndroidEventProcessor: the three catches aroundFuture.get()now catchInterruptedException(restoring the interrupt flag) andExecutionException.ContextUtils.getFamilyandBuildInfoProvider.isEmulator:NullPointerException, sinceBuildfields are only null off-device. Their signatures are unchanged.ContextUtils, which guarded nothing.ANRWatchDogkeeps catchingOutOfMemoryErrorfromgetProcessesInErrorStatebefore its boundary arm, as Swallow error when reading ActivityManager#getProcessesInErrorState instead of crashing #2114 decided.SentryAndroid.initoverloads that take a configuration now say that init continues with the options set before the configuration threw, that fatal errors are rethrown, and that the failure is logged at ERROR, which prints only withdebugenabled.💡 Motivation and Context
This is the Android part of the
rethrowIfFatalboundary pass. It relies on the core part below it in the stack. For example,SentryAndroid.initrethrows a fatal error from the configuration callback, whichSentry.inithas to rethrow too.💚 How did you test it?
ANRWatchDogkeeps running after anOutOfMemoryErrorand stops on aStackOverflowError;NativeEventCollectorhandles a non-numeric item length and a non-object payload; aSentryAndroidconfiguration handler that throws still leaves the SDK enabled.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
#skip-changelog
🤖 Generated with Claude Code