Skip to content

Commit 84b028b

Browse files
Fix enumerating loaded process modules on Apple platforms (#5487)
- This logic always assumed that the lowest address of a mapped file was its "base address", but in the presence of dotnet/runtime#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
1 parent 2650c60 commit 84b028b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/shared/pal/src/thread/process.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,10 @@ CreateProcessModules(
23712371
}
23722372
}
23732373

2374-
if (!dup)
2374+
// Does the offset in the module correspond to a valid MachO header?
2375+
bool mightBeMachOHeader = rwpi.prp_prinfo.pri_offset == 0;
2376+
2377+
if (!dup && mightBeMachOHeader)
23752378
{
23762379
int cbModuleName = strlen(moduleName) + 1;
23772380
ProcessModules *entry = (ProcessModules *)malloc(sizeof(ProcessModules) + cbModuleName);

0 commit comments

Comments
 (0)