I implemented the android NDK recently to hide my app keys and secrets. Since I did that whenever I run my app in debug mode in android studio, my breakpoints get interrupted with sigsegv (signal sigsegv: invalid address (fault address: 0x8)). This occurs when any of my processes access the NDK at all. I'm baffled as to what's happening as I am very new with the NDK. My C code is extremely simple, and looks something like:
#include <jni.h>
JNIEXPORT jstring JNICALL
Java_com_my_company_co_utilities_UtilFuncs_getSecretOne(JNIEnv *env, jobject instance) {
return (*env)-> NewStringUTF(env, "my_secret_1");
}
JNIEXPORT jstring JNICALL
Java_com_my_company_co_utilities_UtilFuncs_getSecretTwo(JNIEnv *env, jobject instance) {
return (*env)-> NewStringUTF(env, "my_secret_2");
}
JNIEXPORT jstring JNICALL
JJava_com_my_company_co_utilities_UtilFuncs_getKeyOne(JNIEnv *env, jobject instance) {
return (*env)-> NewStringUTF(env, "my_key_1");
}
JNIEXPORT jstring JNICALL
Java_com_my_company_co_utilities_UtilFuncs_getKeyTwo(JNIEnv *env, jobject instance) {
return (*env)->NewStringUTF(env, "my_key_2");
}
and I access it in my static UtilFuncs class like:
static {
System.loadLibrary("keys");
}
public static native String getSecretOne();
public static String getSecret() {
return getSecretOne();
}
It works perfectly when I run the app normally, but it has made debug unusable entirely because of these sigsegv: invalid address errors coming up when I'm trying to read watch variables. Anyone encounter this before or have any idea what I'm doing wrong?
Update: The error is not thrown on phones updated to Android 9, so my problem is resolved, but I still have no idea what was causing it in the first place. Would still be interested in any theories on the original cause.
I discovered this thread when I experience the same: a SIGSEGV fault when running my app in the Android Studio (v3.2.1) debugger after adding NDK code. Running it without the debugger executes normally.
I have not found a solution, however I found a further clue.
After the debugger traps the SIGSEGV fault, open the breakpoints dialog.
This shows an active breakpoint at 'libart.so: art_sigsegv_fault':
There appears to be some history of sigsegv faults in libart. I did not find any resolution. However, disabling this breakpoint did allow me to continue to debug my application (a work-around).
If you sure your C code always work fine, maybe you want to ignore error like this and debug in java. Change "Debug Configuration"-"Debug Type" from any to "Java Only"
guide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With