Repository navigation
Description
Description
On Android devices with Armv8.3+ Pointer Authentication, native crash stack traces captured by the NDK integration end after one or two frames. The first caller frame comes back as a raw PAC-signed return address. It does not fall into any loaded image, so unwinding stops there and the server cannot symbolicate it.
The cause looks like strip_pac() in external/libunwindstack-ndk/RegsArm64.cpp (submodule commit 284202fb1e42dbeba6598e26ced2e1ec404eecd1, still the pinned commit on master):
static uint64_t strip_pac(uint64_t pc, uint64_t mask) {
if (mask) {
pc &= ~mask;
} else {
#ifdef SENTRY_REMOVED
#if defined(__BIONIC__)
pc = __bionic_clear_pac_bits(pc);
#endif
#endif // SENTRY_REMOVED
}
return pc;
}pac_mask_ is initialised to 0 and nothing calls RegsArm64::SetPACMask(): neither the fork nor src/unwinder/sentry_unwinder_libunwindstack.cpp. The __bionic_clear_pac_bits() fallback is compiled out. So when CFI marks the return address as signed (DW_CFA_AARCH64_negate_ra_state), set_pc() and fallback_pc() keep the signed value and the walk ends.
Evidence from production events (sentry-android 8.21.1 via sentry_flutter 9.8.0, event SDK sentry.native.android.flutter 0.10.0):
The same crash, a Dart VM Assert::Fail inside libflutter.so (Flutter 3.38.9 engine), shows up as two different issues depending on the CPU:
- Without PAC (e.g. Redmi Note 9, Helio G85, Android 11) we get 4 frames:
abort libc.so dart::Assert::Fail assert.cc:54 DLRT_GetFfiCallbackMetadata runtime_entry.cc <unknown> - With PAC (vivo I2407 / Snapdragon SM7635, Android 16; Samsung SM-S911B / SM8550, Android 14; Samsung SM-S948B / SM8850, Android 16) we get 2 frames:
abort libc.so + 0xbacd0 <unknown> 0x6335f2b82c5834 (no image)
After masking the second frame to the 39-bit user VA (addr & 0x7fffffffff), it lands at the same offset in every event we checked, across devices: libflutter.so + 0x887834 (image code_id 0a7fde9baaf490ad50a8480ebc422ea4ee862a2e). llvm-symbolizer on the matching unstripped libflutter.so resolves it to dart::Assert::Fail at assert.cc:54. That is the same frame Sentry symbolicates fine on non-PAC devices. The other upper bits differ per event (0x6335…, 0x4f3f…, 0x1c86…), as expected for PAC signatures.
Besides the lost frames, this splits one crash into two issues, because the grouping key differs.
When does the problem happen
- During build
- During run-time
- When capturing a hard crash
Environment
- OS: Android 14–16, arm64-v8a, Armv8.3+ CPUs with PAC (Snapdragon SM7635 / SM8550 / SM8850)
- SDK: sentry-android 8.21.1 (bundled sentry-native 0.10.0), through sentry_flutter 9.8.0
- Backend: default Android NDK integration (inproc + libunwindstack)
Steps To Reproduce
- Build an app with native code compiled with
-mbranch-protection=pac-ret(the Flutter engine is one such library), or any library whose CFI usesDW_CFA_AARCH64_negate_ra_state. - Trigger
abort()from inside a PAC-protected function, so the caller's return address is signed. - Run on an Armv8.3+ device with PAC enabled and look at the captured native event: the frame after the crashing function has the PAC bits still set and the stack ends there.
Possible fix
Restore a stripping fallback that does not depend on __bionic_clear_pac_bits() (it is not exported by the NDK). For example, xpaclri encoded as hint #7, which avoids the assembler issue from #1123 and is a NOP on pre-8.3 CPUs:
static uint64_t strip_pac(uint64_t pc, uint64_t mask) {
if (mask) {
return pc & ~mask;
}
#if defined(__aarch64__)
register uint64_t x30 __asm__("x30") = pc;
__asm__("hint #7" : "+r"(x30)); // xpaclri
pc = x30;
#endif
return pc;
}An alternative is to set a mask when getauxval(AT_HWCAP) & HWCAP_PACA is set (regs->SetPACMask(...) right after CreateFromUcontext / CreateFromLocal).
Log output
Not available: these are production crashes from end-user devices. Happy to share more frame and image data from the events if useful.
Activity
linear-code commentedon Oct 27, 2026
NATIVE-240
Scryptolog1st commentedon Oct 27, 2026
Same issue with the React Native SDK:
@sentry/react-native7.11.0 (sentry-android 8.31.0,sentry.native.android.react-native0.12.3) on a Samsung SM-S938U, Android 17 (paca/pacg). A controlledstd::abort()in an app library givesabort(libc) plus one unmapped PAC-signed frame; masking to 39 bits lands exactly on the return address afterbl abortin our library.src/unwinder/sentry_unwinder_libunwindstack.cppand the pinnedlibunwindstack-ndkcommit (284202fb) are unchanged up to 0.17.4, so upgrading alone doesn't help.Workaround confirmed:
@sentry/react-native8.25.0 (sentry-android 8.55.0) withenableTombstone: truemerges the Android tombstone and produces the full stack (23 frames:abort→ app frames → JNI → ART → thread start), fully symbolicated.fix(android): unwind past PAC-signed return addresses
fix(arm64): unwind past PAC-signed return addresses
fix(arm64): unwind past PAC-signed return addresses
fix(arm64): unwind past PAC-signed return addresses (#12)
fix(android): unwind past PAC-signed return addresses (#2263)