Skip to content

Commit

Permalink
Do not patch PLT stubs for MallocStackLogging in MacOS
Browse files Browse the repository at this point in the history
MacOS has some memory interposition libraries that can make us crash
(via stackoverflow when initializing TLS variables) if we patch them.
This is because these libraries interact in a way we cannot avoid with
libdyld, which in turn sets the TLS on first init.
  • Loading branch information
pablogsal committed Oct 5, 2023
1 parent 0348de8 commit 8072257
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/memray/_memray/macho_shenanigans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ patch_symbols_in_shared_object(
<< section->sectname << ")";
continue;
}
// MacOS has some memory interposition libraries that can make us crash (via
// stackoverflow when initializing TLS variables) if we patch them. This is because these
// libraries interact in a way we cannot avoid with libdyld, which in turn sets the TLS
// on first init.
if (strstr(image_name, "MallocStackLogging")) {
LOG(DEBUG) << "Skipping section " << i << " (" << section->segname << ":"
<< section->sectname << ")";
continue;
}
LOG(DEBUG) << "Patching section " << i << " (" << section->segname << ":"
<< section->sectname << ")";
patch_stubs(section, slide, dyninfo_table, restore_original);
Expand Down

0 comments on commit 8072257

Please sign in to comment.