Use mach_vm_read_overwrite to read image infos for dyld_images#403
Merged
Conversation
ianks
reviewed
Oct 31, 2024
ianks
reviewed
Oct 31, 2024
ianks
reviewed
Oct 31, 2024
ianks
reviewed
Oct 31, 2024
| mach_vm_read_overwrite(task, info_array_elem_addr, size, &mut image_info as *mut MaybeUninit<dyld_image_info> as u64, &mut size).into_result()?; | ||
| } | ||
|
|
||
| if size != mem::size_of::<dyld_image_info>() as u64 { |
There was a problem hiding this comment.
We should also check that the result of mach_vm_read_overwrite was KERN_SUCCESS, I think
Contributor
Author
There was a problem hiding this comment.
into_result does it
Contributor
Author
Owner
|
Thank you @Maaarcocr for the patch, @ianks for the review and @casperisfine for testing! |
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.



As I've explained in #389 (comment) it seems like the mapped memory that samply relies on to read image infos for dyld_images is no longer kept up to date with the newest version of macOS.
This results in samply not being able to reconcile from where an address is coming from (as it was shown in the issue I already linked) and thus then we get no symbolication whatsover.
I have a simple solution for this (which I understand may not be desirable from a perf POV): for image infos just read them directly from the other process memory using
mach_vm_read_overwrite. This may be slower, but it at least get samply working again when people use dlopen in the application code. Also, even if it is slower, hopefully people are not constantly dlopen-ing new libraries so this code should only be called few times at startup and that should be it hopefully?