Repository navigation
fix(native): resolve symbol names in crash stacktraces on macOS - #1856
Merged
Merged
Conversation
The crash daemon had no symbol resolution on macOS: the ELF resolver covers Linux/Android only and the dbghelp path is Windows-only, so frames carried bare instruction addresses and the external crash reporter displayed unreadable stacks. Resolve names from the Mach-O symbol table of the containing module (fat/universal-aware, scanned in fixed-size chunks and cached per module). Since nlist entries carry no size, matches are bounded by LC_FUNCTION_STARTS - only a symbol placed exactly at the containing function's entry is accepted, so addresses in symbol-table gaps stay unresolved instead of being attributed to neighboring functions. Files are validated by LC_UUID equality with the loaded image, and stripped modules fall back to the dSYM companion (checked both next to the binary and next to the enclosing .app bundle), validated the same way.
tustanivsky
marked this pull request as ready for review
July 10, 2026 13:49
macho_locate_symtab zeroes the whole macho_sym_info_t, so the state set
at function entry was wiped by the first candidate probe. When no usable
companion was found the slot stayed at 0 ("unresolved") and the dSYM
search re-ran for every frame in the module instead of once.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 443094a. Configure here.
mujacica
approved these changes
Jul 10, 2026
jpnurmi
approved these changes
Jul 12, 2026
jpnurmi
left a comment
Collaborator
There was a problem hiding this comment.
Now that all integration-tested desktop platforms are covered, we could drop the "win32 or linux" conditions in test_integration_native.py:
sentry-native/tests/test_integration_native.py
Lines 997 to 1001 in 252e4c6
sentry-native/tests/test_integration_native.py
Lines 1044 to 1048 in 252e4c6
On arm64e the kernel signs the pointer registers in the delivered thread state and return addresses on the stack are signed by pacibsp. The signature bits sit above the 47-bit macOS user address space, so signed addresses failed the module bounds check and no frame could be matched to a module or resolved to a symbol name. Strip the non-address bits from ip/fp/sp taken from the thread state and from values read off the stack during the frame-pointer walk. On plain arm64 user-space addresses fit in 47 bits, so the mask is a no-op.
1 task
Closed
1 of 3 tasks
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
sentry-native 0.15.4 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`. - [ ] `resource` blocks have been checked for updates. <details> <summary>release notes</summary> <pre>**Features**: - Add reusable, user-owned scopes. `sentry_scope_new` creates a scope that `sentry_capture_event_with_scope` applies without consuming, so you can configure it once and reuse it across many captures instead of building a new local scope each time. `sentry_scope_clone` copies a scope, and `sentry_scope_free` releases it. ([#1855](getsentry/sentry-native#1855)) - Android: Expose setting the environment on the scope through the NDK bindings via `NativeScope.setEnvironment()`, so head SDKs can sync the environment at runtime. ([#1874](getsentry/sentry-native#1874)) - Embed the crash event's breadcrumbs into session replay recordings, so breadcrumbs from the replay window show up on the replay timeline. ([#1875](getsentry/sentry-native#1875)) - Add `sentry_transaction_discard` and `sentry_span_discard` for releasing unfinished transactions and spans without sending them. ([#1858](getsentry/sentry-native#1858)) - Add scope attributes. `sentry_scope_set_attribute` / `_n` set an attribute on a scope and `sentry_scope_remove_attribute` / `_n` remove one, while the new `sentry_scope_capture_log` and `sentry_scope_capture_metric` capture a log or metric against a given scope. Scope attributes and trace are applied to logs and metrics captured against it, resolving most-specific-first: per-call data, then the scope, then the global scope. ([#1861](getsentry/sentry-native#1861)) - Add `sentry_scope_clear` to reset a scope's data. ([#1881](getsentry/sentry-native#1881)) **Deprecations**: - Deprecate `sentry_capture_event_with_scope` in favor of `sentry_scope_capture_event` (scope first), which matches `sentry_scope_capture_log` / `sentry_scope_capture_metric`. ([#1882](getsentry/sentry-native#1882)) **Fixes**: - Apply the propagation context to events that already have contexts set, so that events captured with a local scope or with event-level contexts keep their trace. ([#1843](getsentry/sentry-native#1843)) - Crashpad: reject runtime control IPC from processes other than the one that started the handler. ([#1853](getsentry/sentry-native#1853)) - Native/macOS: resolve symbol names for crash stacktraces from Mach-O symbol tables and dSYM companions. ([#1856](getsentry/sentry-native#1856)) - Route libcurl debug output through the Sentry logger (`SENTRY_TRACE`) instead of writing to `stderr`. ([#1854](getsentry/sentry-native#1854)) - NOTE: `sentry_options_set_debug(options, true)` no longer displays verbose libcurl debug output by default. To restore it, call `sentry_options_set_logger_level(options, SENTRY_LEVEL_TRACE)`. - Crashpad: route client logs through the Sentry logger to make actionable handler startup errors visible. ([#1859](getsentry/sentry-native#1859)) - Windows: fix symlink detection used to prevent database cleanup from following symlinks in run and cache directories. ([#1857](getsentry/sentry-native#1857)) - Linux: avoid unsafe `copy_file_range` at crash time. ([#1868](getsentry/sentry-native#1868)) - Increase the default telemetry batcher capacity from 2x100 to 3x100 items, and add `SENTRY_BATCHER_BUFFER_COUNT` to configure the number of rotating buffers used by log and metric batchers. ([#1867](getsentry/sentry-native#1867)) - Fix a lifetime issue when reading `sample_rand` from the scope propagation context. ([#1869](getsentry/sentry-native#1869)) - Linux: silence harmless compilation warnings in `sentry_modulefinder_linux.c` and `sentry_backend_inproc.c`. ([#1871](getsentry/sentry-native#1871)) - Fix per-call log and metric attributes to override same-named global attributes atomically, preventing fields such as `unit` from leaking from the global attribute when the per-call attribute does not define them. ([#1879](getsentry/sentry-native#1879)) - Prefix vendored mpack symbols to avoid symbol conflicts. ([#1880](https://github.com/getsentry/sentry-native/pull/1880))</pre> <p>View the full release notes at <a href="https://github.com/getsentry/sentry-native/releases/tag/0.15.4">https://github.com/getsentry/sentry-native/releases/tag/0.15.4</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!14800
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.

This PR fixes address-only crash callstacks produced by the
nativebackend on macOS - frames carried bareinstruction_addrs with no function names, so the Sentry's external crash reporter (and any consumer of the client-side event) displayed unreadable stacks.Problem
The crash daemon has no symbol resolution on macOS.
enrich_frame_with_symbolis compiled for Linux/Android only (ELF, #1836) and the Windows path resolves names throughdbghelp(#1811). On macOS the daemon's frame-pointer walk only attached the containing module to each frame and never setfunction.Proposed fix
Implement the macOS counterpart of the ELF resolver in the daemon:
LC_SYMTAB/nlist_64) of the containing module, read from disk out-of-process. Universal (fat) binaries are resolved to the slice matching the daemon's architecture. Tables are scanned in fixed-size chunks with only the winning name read from the string table, and the resolved source is cached per module - large tables are never loaded wholesale.LC_FUNCTION_STARTS:nlistentries carry no size (unlike ELFst_size), so a name is only accepted when a symbol sits exactly at the entry of the function containing the address. The payload survivesstrip, so addresses in symbol-table gaps stay unresolved instead of being attributed to unrelated neighboring functions - an unresolved frame beats a wrong name.LC_UUIDequality with the loaded image (the Mach-O analog of the GNU build-id check). This also correctly rejects on-disk stubs of system dylibs that don't match the dyld-shared-cache images actually loaded; those frames are left for server-side symbolication.<X>.dSYM/Contents/Resources/DWARF/<binary>) when the module's own table misses (stripped local symbols), checked both next to the binary and next to the enclosing.appbundle (the UE packaged-game layout), UUID-validated.Testing
Checked manually against a UE 5.8 sample project (packaged Development build, macOS) by capturing a null-pointer crash:
Related items