Skip to content

Commit 0ee65e9

Browse files
runningcodeclaude
andauthored
feat(samples): Make Native Crash button fault inside app native code (#5773)
The Native Crash button called raise(SIGSEGV), which faults inside libc and, for a JNI-originated crash, does not exercise symbolication of the app's own native code. Point it at a null-deref inside a named function (trigger_null_deref) instead, so the crashing frame resolves to a real symbol + source line and native symbolication can be verified from the sample. Ref JAVA-645 Claude-Session: https://claude.ai/code/session_01EmE8hdaj9H9K61opK2PZ6U Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5ed4fea commit 0ee65e9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

sentry-samples/sentry-samples-android/src/main/cpp/native-sample.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
#include <jni.h>
22
#include <android/log.h>
33
#include <sentry.h>
4-
#include <signal.h>
54

65
#define TAG "sentry-sample"
76

87
extern "C" {
98

9+
// Faults inside this named function so the crashing frame resolves to a real
10+
// symbol + source line. A bare raise(SIGSEGV) would instead fault in libc and,
11+
// for a JNI-originated crash, not exercise app-native symbolication.
12+
[[gnu::noinline]]
13+
static void trigger_null_deref() {
14+
volatile int *ptr = nullptr;
15+
*ptr = 42;
16+
}
17+
1018
JNIEXPORT void JNICALL Java_io_sentry_samples_android_NativeSample_crash(JNIEnv *env, jclass cls) {
1119
__android_log_print(ANDROID_LOG_WARN, TAG, "About to crash.");
12-
raise(SIGSEGV);
20+
trigger_null_deref();
1321
}
1422

1523
JNIEXPORT void JNICALL Java_io_sentry_samples_android_NativeSample_message(JNIEnv *env, jclass cls) {

0 commit comments

Comments
 (0)