-
Notifications
You must be signed in to change notification settings - Fork 383
Fix enumerating loaded process modules on Apple platforms #5487
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
Fix enumerating loaded process modules on Apple platforms #5487
Conversation
- This logic always assumed that the lowest address of a mapped file was its "base address", but in the presence of #114462 that is no longer correct. We may map stubs at lower addresses. - Fix by checking the start of the mapped region for the magic value for the start of a MachO binary
ssize_t bytesRead = read(fd, &magic, sizeof(magic)); | ||
if (bytesRead == sizeof(magic)) | ||
{ | ||
if (magic == 0xFEEDFACF) |
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.
if (magic == 0xFEEDFACF) | |
if (magic == 0xFEEDFACF || magic == 0xFEEDFACE) |
Looks like a few of the mappings have 0-offset entries:
And attaching with a debugger - only the first one has the machO magic, despite all claiming offset 0. |
yeah - we considered this as a "next possible thing". Remote reads just come with their own cost. We have similar logic in: https://github.com/dotnet/diagnostics/blob/main/src/Microsoft.FileFormats/MachO/MachOFatHeaderStructures.cs#L29 |
Note in case this bites us in the future: flags isn't the most reliable here. There's the "cheaper" way of checking the remote bytes for the magic. The other option is using vm_* APIs to recognize the __TEXT section load. |
Uh oh!
There was an error while loading. Please reload this page.