-
-
Notifications
You must be signed in to change notification settings - Fork 204
fix: image size computation on Apple #1740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+40
−12
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bb6da5d
image size computation
bitsandfoxes 41abde4
comment
bitsandfoxes d59c335
comments
bitsandfoxes 12621be
comments
bitsandfoxes 1c5a178
stripped tests to validate no overlap
bitsandfoxes 637a547
naming is hard
bitsandfoxes 0618d24
tightening
bitsandfoxes 5b1704e
updated changelog
bitsandfoxes 5858061
comment
bitsandfoxes 1762913
Update CHANGELOG.md
bitsandfoxes 692b628
Merge branch 'master' into fix/apple-imagesize
bitsandfoxes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,6 +182,29 @@ def assert_event_meta( | |
| ) | ||
|
|
||
|
|
||
| def assert_debug_meta_images_do_not_overlap(event): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
| """Validate ``event["debug_meta"]["images"]`` shape. | ||
|
|
||
| The half-open ranges ``[image_addr, image_addr + image_size)`` must not | ||
| overlap -- the symbolicator relies on this to attribute frames to images. | ||
| """ | ||
| images = event["debug_meta"]["images"] | ||
| assert len(images) > 0, "debug_meta should contain at least one image" | ||
|
|
||
| ranges = [] | ||
| for image in images: | ||
| name = image.get("code_file") or image.get("debug_file") or "<unknown>" | ||
| addr = int(image["image_addr"], 16) | ||
| ranges.append((addr, addr + image["image_size"], name)) | ||
|
|
||
| ranges.sort() | ||
| for (a_start, a_end, a_name), (b_start, b_end, b_name) in zip(ranges, ranges[1:]): | ||
| assert a_end <= b_start, ( | ||
| f"image ranges overlap: {a_name} [{a_start:#x}, {a_end:#x}) " | ||
| f"vs {b_name} [{b_start:#x}, {b_end:#x})" | ||
| ) | ||
|
|
||
|
|
||
| def is_valid_hex(s): | ||
| if not s.lower().startswith("0x"): | ||
| return False | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop walks Mach-O load commands looking for two things:
__TEXTsegment'svmsizeLC_UUIDThe new
has_size/has_uuidflags let the loop short-circuit once both are found. So we don't have to iterate through every remaining load command.