fix: image size computation on Apple#1740
Merged
Merged
Conversation
bitsandfoxes
commented
May 22, 2026
Comment on lines
+565
to
+569
| bool has_size = false; | ||
| bool has_uuid = false; | ||
|
|
||
| for (uint32_t j = 0; j < header64->ncmds && j < 256; j++) { | ||
| for (uint32_t j = 0; | ||
| j < header64->ncmds && j < 256 && (!has_size || !has_uuid); |
Contributor
Author
There was a problem hiding this comment.
The loop walks Mach-O load commands looking for two things:
- the
__TEXTsegment'svmsize - the
LC_UUID
The new has_size/has_uuid flags let the loop short-circuit once both are found. So we don't have to iterate through every remaining load command.
bitsandfoxes
commented
May 22, 2026
| ) | ||
|
|
||
|
|
||
| def assert_debug_meta_images_do_not_overlap(event): |
Contributor
Author
There was a problem hiding this comment.
If I read that correctly then on darwin platforms we get a list of modules loaded, which basically guarantees that images and image addresses do not overlap. Adding this as regression proofing.
mujacica
approved these changes
May 22, 2026
jpnurmi
approved these changes
May 22, 2026
Co-authored-by: J-P Nurmi <jpnurmi@gmail.com>
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Fixes
- image size computation on Apple ([#1740](https://github.com/getsentry/sentry-native/pull/1740))If none of the above apply, you can opt out of this check by adding |
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.
On macOS arm64 the native crash handler computed each module's image_size as
max(seg->vmaddr + seg->vmsize)across allLC_SEGMENT_64commands. For dyld-shared-cache librariesseg->vmaddris a shared-cache-absolute address, not relative to the image base, so the result lands in the multi-GB range. Every system image's half-open range[image_addr, image_addr + image_size)then overlaps every other. This caused the symbolicator to attribute every frame to whichever image has the lowestimage_addr. Turns out that typically is dyld or the first libsystem module.See misattribution:
We already use
__TEXTinsentry_modulefinder_apple.csentry-native/src/modulefinder/sentry_modulefinder_apple.c
Lines 65 to 67 in 82dec4b
to get to the correct per-image extent.
So now it looks like