Skip to content

fix(android): unwind past PAC-signed return addresses - #2263

Merged
jpnurmi merged 7 commits into
masterfrom
jpnurmi/fix/android-pac
Oct 30, 2026
Merged

jpnurmi merged 7 commits into
masterfrom
jpnurmi/fix/android-pac

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Depends on:

On Armv8.3+ devices, native stack traces ended at the first PAC-signed return address, because libunwindstack-ndk only stripped PAC with a mask that nothing sets. Bump it to strip with xpaclri like bionic does.

Note: We don't have Android ARM64 covered by the CI, so getsentry/libunwindstack-ndk#12 was manually tested. See details in the PR description.

Fixes: #2258

Another mapping of an APK library's ELF header can lie anywhere in the
address space. `is_duplicated_mapping()` accepted any mapping with the
same inode and file offset, so without another module in between, the
library merged into the earlier mapping, with a wrong `image_addr` and
an `image_size` covering both.

Accept such a mapping only within the module's `PT_LOAD` span. Share
the program header walk with `get_code_id_from_program_header()` via
`ELF_PROGRAM_HEADER_ITER`.

Fixes: #2261
@jpnurmi
jpnurmi added this pull request to stack #2264 October 28, 2026 09:55
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.57%. Comparing base (39ab761) to head (360379e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2263      +/-   ##
==========================================
+ Coverage   75.53%   75.57%   +0.03%     
==========================================
  Files         103      103              
  Lines       28315    28315              
  Branches     5203     5203              
==========================================
+ Hits        21389    21400      +11     
+ Misses       5578     5570       -8     
+ Partials     1348     1345       -3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The test mapped the executable's ELF header again twice its file size
below it, assuming its load range is smaller. Clang links the TSAN
runtime statically, and its `.bss` makes the load range about four
times the file size, so the mapping landed inside it, where it still
merges by design.

Size the gap from the executable's `PT_LOAD` segments instead.
On Armv8.3+ devices, native stack traces ended at the first
PAC-signed return address, because libunwindstack-ndk only stripped
PAC with a mask that nothing sets. Bump it to strip with `xpaclri`
like bionic does.

Fixes: #2258
@jpnurmi
jpnurmi force-pushed the jpnurmi/fix/android-pac branch from b649fde to 21b50df Compare October 28, 2026 10:47
Base automatically changed from jpnurmi/fix/android-modules to master October 29, 2026 11:02
@jpnurmi
jpnurmi merged commit ed74e23 into master Oct 30, 2026
70 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/fix/android-pac branch October 30, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android/arm64: native stack traces stop at the first PAC-signed return address (libunwindstack-ndk never strips PAC)

2 participants