-
-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When native code calls a JNI method (Kotlin/Java) and there is a crash in the Kotlin side the crash isn't sent to Sentry #4138
Comments
@ramib85 Thanks for bringing this up, we'll have a look at this shortly! |
an example of how such crash looks like in logcat:
|
Hey everyone, thanks for all the details! I finally had some time to look into this and it seems that our SDK is behaving as expected. Having said that, a few notes: If the following code gets executed, and the JNIEXPORT void JNICALL
Java_io_sentry_samples_android_example(JNIEnv *env, jclass cls) {
jmethodID javaCrashMethod = env->GetStaticMethodID(cls, "javaCrash", "()V");
env->CallStaticVoidMethod(cls, javaCrashMethod); // Java exception is marked as pending
} // Java's UncaughtExceptionHandler will be called after execution However if your C++ code performs other Java calls after a Java error was thrown previously, you'll get a native C++ crash, as you're not supposed to make certain JNI calls if your Java layer has a pending exception JNIEXPORT void JNICALL
Java_io_sentry_samples_android_example(JNIEnv *env, jclass cls) {
jmethodID javaCrashMethod = env->GetStaticMethodID(cls, "javaCrash", "()V");
env->CallStaticVoidMethod(cls, javaCrashMethod); // Java exception is marked as pending
// Causes native ABORT crash, as it's not allowed to call GetStaticMethodID while an exception is pending
env->GetStaticMethodID(cls, "javaCrash", "()V");
} It's worth noting that native crashes will be reported to sentry.io on the next app start only, for Java crashes the Sentry SDK will try to report them immediatelly. There are different ways around this, see the Android docs for more details. |
Integration
sentry-android
Build System
Gradle
AGP Version
8.7.2
Proguard
Enabled
Version
7.20.0
Steps to Reproduce
throw Throwable("test exception")
.A native "abort" crash occurs when this happens and appears in logcat but it isn't sent to Sentry website (or I can't seem to find these crashes).
Example from actual project.
The native code calls this Kotlin function
Native code in Rust that calls the function above using JNI:
env is defined as
env: &'a JNIEnv
Expected Result
A native abort crash is reported in Sentry website.
Actual Result
App crashes but the crash doesn't appear in Sentry website.
The text was updated successfully, but these errors were encountered: