Skip to content

Preserve ARM64 PAC masks in Linux core dumps - #137777

Merged
max-charlamb merged 6 commits into
dotnet:mainfrom
max-charlamb:createdump-linux-arm64-pac-mask
Nov 18, 2026
Merged

max-charlamb merged 6 commits into
dotnet:mainfrom
max-charlamb:createdump-linux-arm64-pac-mask

Conversation

@max-charlamb

@max-charlamb max-charlamb commented Nov 17, 2026 •

Copy link
Copy Markdown
Member
  • Capture the Linux ARM64 NT_ARM_PAC_MASK regset for each thread and write it as a LINUX ELF core note when available.
  • Include emitted notes in the PT_NOTE size and report unexpected regset failures without preventing dump creation.
  • This allows native tooling to unwind dumps created with createdump when the system has ARM-PAC enabled.

Related to #109457.

Validation (A/B on Ubuntu 26.04 / glibc 2.43, both using dotnet/diagnostics#6256). The temporary queue change used for validation (dd159c9) has been reverted from this PR; the baseline carries only that queue change:

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@max-charlamb max-charlamb changed the title Preserve ARM64 PAC masks in Linux core dumps Preserve ARM64 PAC metadata in Linux and macOS core dumps Nov 17, 2026
@max-charlamb max-charlamb changed the title Preserve ARM64 PAC metadata in Linux and macOS core dumps Preserve ARM64 PAC masks in Linux core dumps Nov 18, 2026
@max-charlamb
max-charlamb marked this pull request as ready for review November 18, 2026 00:49
Match the diagnostics CI queue so PAC-signed return addresses are exercised.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: d35a41b1-6332-4188-8ee8-793457babe03
Co-authored-by: Copilot <[email protected]>
Copilot-Session: d35a41b1-6332-4188-8ee8-793457babe03
Validation-only; the queue change is tracked separately in dotnet#137796.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: d35a41b1-6332-4188-8ee8-793457babe03
@max-charlamb
max-charlamb merged commit 2e314e7 into dotnet:main Nov 18, 2026
100 of 102 checks passed
@max-charlamb

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@max-charlamb backporting to release/11.0 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git cherry-pick 2e314e7a7d6888c4fb1494b3dee8a66d6425c521

Auto-merging src/coreclr/debug/createdump/dumpwriterelf.h
CONFLICT (content): Merge conflict in src/coreclr/debug/createdump/dumpwriterelf.h
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/createdumpcore.h deleted in HEAD and modified in 2e314e7a7d6 (Preserve ARM64 PAC masks in Linux core dumps (#137777)).  Version 2e314e7a7d6 (Preserve ARM64 PAC masks in Linux core dumps (#137777)) of src/coreclr/debug/createdump/shared/createdumpcore.h left in tree.
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/dumpwriterelf.cpp deleted in HEAD and modified in 2e314e7a7d6 (Preserve ARM64 PAC masks in Linux core dumps (#137777)).  Version 2e314e7a7d6 (Preserve ARM64 PAC masks in Linux core dumps (#137777)) of src/coreclr/debug/createdump/shared/dumpwriterelf.cpp left in tree.
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/threadsnapshot.cpp deleted in HEAD and modified in 2e314e7a7d6 (Preserve ARM64 PAC masks in Linux core dumps (#137777)).  Version 2e314e7a7d6 (Preserve ARM64 PAC masks in Linux core dumps (#137777)) of src/coreclr/debug/createdump/shared/threadsnapshot.cpp left in tree.
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/threadsnapshot.h deleted in HEAD and modified in 2e314e7a7d6 (Preserve ARM64 PAC masks in Linux core dumps (#137777)).  Version 2e314e7a7d6 (Preserve ARM64 PAC masks in Linux core dumps (#137777)) of src/coreclr/debug/createdump/shared/threadsnapshot.h left in tree.
error: could not apply 2e314e7a7d6... Preserve ARM64 PAC masks in Linux core dumps (#137777)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"


$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Preserve ARM64 PAC masks in Linux core dumps
Using index info to reconstruct a base tree...
A	src/coreclr/debug/createdump/shared/createdumpcore.h
A	src/coreclr/debug/createdump/shared/dumpwriterelf.cpp
A	src/coreclr/debug/createdump/shared/dumpwriterelf.h
A	src/coreclr/debug/createdump/shared/threadsnapshot.cpp
A	src/coreclr/debug/createdump/shared/threadsnapshot.h
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/debug/createdump/dumpwriterelf.h
CONFLICT (content): Merge conflict in src/coreclr/debug/createdump/dumpwriterelf.h
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/createdumpcore.h deleted in HEAD and modified in Preserve ARM64 PAC masks in Linux core dumps.  Version Preserve ARM64 PAC masks in Linux core dumps of src/coreclr/debug/createdump/shared/createdumpcore.h left in tree.
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/dumpwriterelf.cpp deleted in HEAD and modified in Preserve ARM64 PAC masks in Linux core dumps.  Version Preserve ARM64 PAC masks in Linux core dumps of src/coreclr/debug/createdump/shared/dumpwriterelf.cpp left in tree.
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/threadsnapshot.cpp deleted in HEAD and modified in Preserve ARM64 PAC masks in Linux core dumps.  Version Preserve ARM64 PAC masks in Linux core dumps of src/coreclr/debug/createdump/shared/threadsnapshot.cpp left in tree.
Auto-merging src/coreclr/debug/createdump/threadinfo.h
CONFLICT (content): Merge conflict in src/coreclr/debug/createdump/threadinfo.h
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Preserve ARM64 PAC masks in Linux core dumps
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 19, 2026
steveisok pushed a commit that referenced this pull request Nov 20, 2026
Backport of #137777 to release/11.0.

Manual backport: the bot cherry-pick conflicted because createdump was
reorganized into `shared/` on main. Changes are ported to the
`release/11.0` layout (`ThreadSnapshot` -> `ThreadInfo`,
`createdumpcore.h` -> `createdump.h`, `CrashInfo::Threads()` holds
`ThreadInfo*`). Logic is unchanged.

## Customer Impact

- [ ] Customer reported
- [x] Found internally

On Linux ARM64 systems where glibc signs return addresses with PAC (e.g.
Ubuntu 26.04 / glibc 2.43), dumps created by createdump omit the
`NT_ARM_PAC_MASK` note. Without it, LLDB cannot strip PAC bits from
return addresses and native stack unwinding stops after the first libc
frames, so crash dumps cannot be fully analyzed.

## Regression

- [ ] Yes
- [x] No

Exposed by newer distros that enable PAC by default; createdump never
wrote this note.

## Testing

dotnet/diagnostics#6256 adds `NativeUnwindTests`, which asserts LLDB
unwinds through multiple runtime frames in a createdump dump. A/B on the
Ubuntu 26.04 ARM64 queue against main: baseline without fix (run
1687082) vs. with fix (run 1687081).

## Risk

Low. ARM64 Linux only. Adds one optional per-thread ELF note when the
kernel exposes the PAC mask regset; failures to read it are logged and
do not prevent dump creation.

Co-authored-by: Max Charlamb <[email protected]>
Co-authored-by: Copilot <[email protected]>
Copilot-Session: d35a41b1-6332-4188-8ee8-793457babe03
max-charlamb added a commit that referenced this pull request Nov 21, 2026
## Summary

#137777 added `NT_ARM_PAC_MASK` support so Linux ARM64 core dumps
preserve the PAC (Pointer Authentication Code) address mask, letting
debuggers correctly strip signed return addresses when unwinding. That
PR also contained a macOS equivalent, but it was reverted
(`c6d46965dcd56ea37441a826457a5f039370e765`) because it hadn't been
built or tested on real macOS/PAC hardware.

This PR reapplies that macOS fix (cherry-picked from the reverted commit
`b4f6b7329b7efa4733918edcae847aa9a911a752`) and validates it end-to-end
on real Apple Silicon PAC hardware.

### What it does

On ARM64 macOS, `createdump` now emits an `LC_NOTE` named `"addrable
bits"` in the Mach-O core dump, containing a version-4 `{version,
lowAddressBits, highAddressBits, reserved}` payload sourced from
`sysctlbyname("machdep.virtual_address_size", ...)`. This matches the
format LLDB/`debugserver` already expect/produce, so LLDB can correctly
determine how many address bits are valid and strip PAC signing bits
from return addresses when unwinding arm64e-signed frames.

- `src/coreclr/debug/createdump/shared/dumpwritermacho.cpp`: adds
`BuildAddressableBitsNote()`, wires it into
`WriteDump()`/`WriteHeader()`.
- `src/coreclr/debug/createdump/shared/dumpwritermacho.h`: adds
`AddressableBitsPayload` struct and related `DumpWriter` members.

### Validation

Performed on a local Apple M3 Pro (confirmed `FEAT_PAuth`,
`FEAT_PAuth2`, `FEAT_FPAC`, `FEAT_PACIMP` all enabled via `sysctl
hw.optional.arm.*`):

1. Built `createdump` with the fix (`osx.arm64.Debug`) and deployed it
into a matching testhost's shared framework directory.
2. Ran a minimal managed app that throws an unhandled exception with
`DOTNET_DbgEnableMiniDump=1 DOTNET_DbgMiniDumpType=4` to produce a full
core dump.
3. Confirmed via `otool -l` that an `LC_NOTE` with `data_owner="addrable
bits"` is present, and manually decoded its 16-byte payload
(`{version=4, lowAddressBits=47, highAddressBits=47, reserved=0}`) —
this **exactly matches** the live `sysctl machdep.virtual_address_size`
value (47) on the machine.
4. To rule out a regression from this change, reproduced an (unrelated,
pre-existing) LLDB crash (`Bus error` in
`ObjectFileMachO::ParseSymtab`/OSO debug-map parsing on this Xcode LLDB
build) identically on dumps produced **with and without** the fix,
confirming it's an environment issue unrelated to this change, not a
regression.

> [!NOTE]
> This PR description and the investigation behind it were drafted with
GitHub Copilot CLI assistance.

Co-authored-by: Max Charlamb <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants