Skip to content

Improved TPanic message for Android#9885

Open
paulorrfilho wants to merge 1 commit intogoogle:mainfrom
paulorrfilho:main
Open

Improved TPanic message for Android#9885
paulorrfilho wants to merge 1 commit intogoogle:mainfrom
paulorrfilho:main

Conversation

@paulorrfilho
Copy link
Copy Markdown

@paulorrfilho paulorrfilho commented Apr 8, 2026

Register the full panic message as the tombstone “Abort message:” so it appears in crash reports (e.g., Google Play Console) that rely on device tombstones instead of logcat output.
Related to #9294 #9075

Register the full panic message as the tombstone “Abort message:” so it appears in crash reports (e.g., Google Play Console) that rely on device tombstones instead of logcat output.
@romainguy
Copy link
Copy Markdown
Contributor

@pixelflinger

@pixelflinger pixelflinger self-requested a review April 13, 2026 17:33
Comment thread libs/utils/src/Panic.cpp
Comment on lines +228 to +234
// Register the full panic message as the tombstone "Abort message:" so that it
// appears in crash reports collected by Google Play Console and other tools that
// read tombstones from field devices (which never have access to logcat output).
#if defined(__ANDROID__)
android_set_abort_message(e.what());
#endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be moved just above the std::abort() call, and after the throw e (if exceptions are enabled, we might not abort).

@pixelflinger pixelflinger added the internal Issue/PR does not affect clients label Apr 13, 2026
Copy link
Copy Markdown
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately android_set_abort_message() is not an official public API. However:

__android_log_default_aborter(const char *abort_message)

Seems to be a public API as of API level 30.

So, we should be able to use __android_log_default_aborter instead of abort() on android if we surround the code with

if (__builtin_available(android 30, *)) {
}

(on Android only).

If we're not on API level 30, then as a workaround, we can maybe use android_set_abort_message() + abort(). But we have to be careful. The best way would be to do this:

extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
if (&android_set_abort_message) {
    android_set_abort_message(str);
}

and avoid including the header entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Issue/PR does not affect clients

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants