coffeecatch
coffeecatch copied to clipboard
Doesn't catch SIGSEGV on Android
I am trying to use COFFEE_TRY_JNI
on Android, but it does not seem to catch the signal. I just copied the coffeecatch source files in my project, and had to remove some of those parts because Android now apparently has them. I only removed what was "duplicated" (keeping the system one and removing the one in coffeecatch.c).
I get the following crash:
Fatal signal 11 (SIGSEGV), code 2, fault addr 0x7969a63cb6 in tid 20990 (DefaultDispatch)
From this code, calling runNative
from Java (well, Kotlin actually):
__attribute__ ((noinline))
static void run() {
char *test = "blah";
*(test + 1) = 'n';
}
__attribute__ ((noinline))
static void run_protected(JNIEnv *env) {
COFFEE_TRY_JNI(env, run());
}
JNIEXPORT void JNICALL
Java_com_example_JniApi_00024Companion_runNative(
JNIEnv *env, jobject thiz) {
run_protected(env);
}
Am I missing something?
I traced it to this line:
siglongjmp(t->ctx, code);
I get my SIGSEGV right when this is called :thinking:.