Repository navigation
Android NDK Segfault crash related to sentry_value_set_by_key_n #974
Copy link
Copy link
Closed
Labels
AndroidBugsomething isn't working as it shouldsomething isn't working as it shouldErrorsissues relates to the error reporting productissues relates to the error reporting productNativeplatform labelplatform label
Description
Description
Our Android project has seen crashes related to a Segfault in Sentry native code. There are no places in our code that are directly calling nativeAddBreadcrumb, so thinking something under the hood in Sentry library is making the call. Still, there seems to be a Segfault bug in sentry native code sentry_value.c's file. Thanks in advance for taking a look, and please let me know if there is additional information I can help provide.
When does the problem happen
- During build
- During run-time
- When capturing a hard crash
Environment
- OS: Have seen crashes on Android 10,12,13,14
- Compiler:
- CMake version and config:
- Sentry version - 7.4.0
- Sentry compose version - 7.4.0
- Sentry gradle plugin version - 4.3.0
Subset of Sentry options enabled
options.enableAllAutoBreadcrumbs(true)
options.isAnrEnabled = true
options.isEnableNdk = true
options.isAttachStacktrace = true
options.isSendDefaultPii = false
options.isEnableScopeSync = true
options.maxBreadcrumbs = 500
options.isEnableAutoSessionTracking = true
options.isAttachThreads = true
options.anrTimeoutIntervalMillis = 10000
options.isAttachScreenshot = false
options.tracesSampleRate = null
options.profilesSampleRate = null
when (configProvider.buildEnvironment) {
Environment.Development -> {
options.maxBreadcrumbs = 700
options.isSendDefaultPii = true
options.isAttachScreenshot = true
options.tracesSampleRate = 1.0
options.profilesSampleRate = 1.0
}
Environment.Alpha, Environment.Beta -> {
options.tracesSampleRate = 0.4
options.profilesSampleRate = 0.4
}
Environment.Production -> {
// use Sonos (and Sentry) default values
}
}
Steps To Reproduce
I myself have not run into this issue and have not found a reliable way to reproduce. Our project has seen the crash approximately 43 times in the past 30 days across 32 users.
Log output
Exception Type: Unknown (SIGSEGV)
Application Specific Information:
Segfault
Thread 0 Crashed:
0 base.apk 0x71ef138ce0 sentry_value_set_by_key_n (sentry_value.c:482)
1 base.apk 0x71ef13ae30 [inlined] sentry_value_set_by_key (sentry_value.c:494)
2 base.apk 0x71ef13ae30 [inlined] timestamp_value (sentry_value.c:1163)
3 base.apk 0x71ef13ae30 sentry_value_new_breadcrumb_n (sentry_value.c:1173)
4 base.apk 0x71ef0b01f4 Java_io_sentry_android_ndk_NativeScope_nativeAddBreadcrumb (sentry.c:174)
5 base.odex 0x7160a890a0 <unknown> + 486952964256
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
AndroidBugsomething isn't working as it shouldsomething isn't working as it shouldErrorsissues relates to the error reporting productissues relates to the error reporting productNativeplatform labelplatform label
Projects
- StatusShow more project fieldsNo status
- StatusShow more project fieldsNo status
Activity
supervacuus commentedon Apr 2, 2024
Hi @aaronjosephsonos, thanks for the report.
Whenever you add breadcrumbs to your Android application, a call will be made to
nativeAddBreadcrumb()because breadcrumbs will be synced to the Native SDK.You might do this directly via any Interface providing an
addBreadcrumb()method or indirectly via an integration that automatically adds them, for instance, during an activity state or navigation change.I understand you currently cannot reproduce this locally, but any additional context (like a logcat output or a tombstone) will be helpful for me. Do you get these reports via Sentry? If so, could you provide a link to one of our employees, karl.struggl@sentry.io, for one such event?
This is the second report from Android, in which a freshly created
objecthas either uninitialized members or refers to memory it doesn't own. AFAICR, this also appeared while adding atimestampto a breadcrumbobject(i.e., the first key to be added). Back then, I thought we might hit an issue with thepage_allocatorbecause it happened in the signal handler, but this seems to be happening outside any raised signal.In any case, I will investigate.
Does this issue appear only with recent updates?
supervacuus commentedon Apr 2, 2024
Cc @kahest: While my hopes are low that we will be able to repro this quickly, this is another concrete driver for #962
aaronjosephsonos commentedon Apr 2, 2024
Thanks for the response @supervacuus!
Ahh thats good to know. We are calling addBreadcumbs pretty often in our code, basically anytime we log something we are calling addBreadcrumbs. So potentially some log message that occasionally occurs may be causing this bug to pop up.
Yes, we get these reports in Sentry. My workplace has a Slack channel with Sentry reps. I will share the events in that channel with them, and hopefully they will be able to forward them to you. I'll keep you posted with that correspondance.
The first crash was reported on February 16, at that time we were on Sentry Android version
6.29.0and Sentry android gradle version3.12.0supervacuus commentedon Apr 2, 2024
I hope it is not a particular log message (although that would make the case easy). The breadcrumbs are a pretty beaten path, especially on mobile, and if the error were in that code, I would be surprised that we're not getting many more reports. But it is hard to say at this point.
Thanks!
26 remaining items
kahest commentedon Mar 24, 2025
@deathlyrage thanks for reaching out. We see only very few events for this crash so it's currently unclear if the version changes affect this. We're investigating and will follow up here
jpnurmi commentedon Sep 1, 2026
It's been 1.5 years since the last report. #1446 addressed a relevant allocator race, while #2035 and #2036 added regression and ASan coverage.
We'll close this for now, but please don't hesitate to let us know if the problem persists.