diag(crash): name the library + offset a userspace SIGSEGV faults in - #745
Merged
Conversation
A dynamically-linked crash (labwc and its libraries) left only `unhandled page fault @ … pc=0x7f…` plus a `Done(139)` — the PC is an absolute address with no indication of which mapping it belongs to, so it could not be symbolised. Add `VmAddressRegion::describe_addr`, which locates the mapping containing an address and returns its base, the byte offset into the backing file (VMO), and the backing object's name (a file path for a file mapping, already set by the file get_vmo path; empty for anonymous memory). The SIGSEGV handler now prints, for both the faulting PC and the bad data address: [crash] pid=N pc 0x7f… in /usr/lib/libwlroots.so.13 + 0x1234 (map base 0x7f…) so the exact fault can be located offline with `addr2line -e <file> 0x<off>` / `objdump`, turning an opaque compositor `Done(139)` into a pinned crash site. Anonymous mappings (heap/stack/JIT) print as `[anon] + off`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MHCn5RNRcwR5PY1sYBHY2S
There was a problem hiding this comment.
Pull request overview
This PR improves userspace crash diagnostics by resolving faulting addresses (PC and fault address) to the owning VM mapping, including mapping base, offset into the backing VMO/file, and the backing object name, so dynamically-linked crashes can be symbolized offline.
Changes:
- Add
VmAddressRegion::describe_addrto locate the mapping containing a virtual address and return(base, offset, name). - Extend the userspace SIGSEGV/page-fault path to log the resolved library/anon mapping and offset for both
pcand the fault address.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| zircon-object/src/vm/vmar.rs | Adds describe_addr helper to map an address to its mapping base, VMO/file offset, and object name. |
| loader/src/linux.rs | Logs resolved mapping information for crash PC and fault address to enable offline symbolization. |
Suppressed comments (1)
zircon-object/src/vm/vmar.rs:1531
file_offis computed withsaturating_sub, which can silently produce an incorrect offset (e.g., if invariants are ever violated andvaddr < inner.addr, this would report the mapping start instead of failing). Since this method already returnsOption, preferchecked_sub/checked_addand returnNoneon underflow/overflow to avoid misleading crash diagnostics.
// File offset of `vaddr`: the VMO offset the mapping starts at plus how
// far `vaddr` is into the mapping.
let file_off = inner.vmo_offset + vaddr.saturating_sub(inner.addr);
Some((inner.addr, file_off, map.vmo.name()))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1525
to
+1527
| pub fn describe_addr(&self, vaddr: usize) -> Option<(VirtAddr, usize, alloc::string::String)> { | ||
| let map = self.find_mapping(vaddr)?; | ||
| let inner = map.inner.lock(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A dynamically-linked crash (labwc and its libraries) left only
unhandled page fault @ … pc=0x7f…plus aDone(139)— the PC is an absolute address with no indication of which mapping it belongs to, so it could not be symbolised. AddVmAddressRegion::describe_addr, which locates the mapping containing an address and returns its base, the byte offset into the backing file (VMO), and the backing object's name (a file path for a file mapping, already set by the file get_vmo path; empty for anonymous memory).The SIGSEGV handler now prints, for both the faulting PC and the bad data address:
[crash] pid=N pc 0x7f… in /usr/lib/libwlroots.so.13 + 0x1234 (map base 0x7f…)
so the exact fault can be located offline with
addr2line -e <file> 0x<off>/objdump, turning an opaque compositorDone(139)into a pinned crash site. Anonymous mappings (heap/stack/JIT) print as[anon] + off.Claude-Session: https://claude.ai/code/session_01MHCn5RNRcwR5PY1sYBHY2S