Skip to content

Commit 6fbadf7

Browse files
pablogsalgodlygeek
authored andcommitted
Do not override symbols in the muslc linker
To avoid deadlocks and infinite recursion, we need to avoid patching symbols inside the linker shared objects. We have been diligently doing this with the GNU linker ("ld-linux") but not for the muslc linker ("ld-musl"). This has been working by chance because we use our recursion guards in many of the symbols we patch, including dlopen. The fact that we override dlopen and we use the guard was preventing a deadlock when using native traces in muslc, as fetching native traces ends adquiring a lock that it's shared by dlopen itself. Now that we do not patch dlopen, there is nothing preventing memray to try to fetch native traces in the inner calls to calloc() and that tries to adquire the dlopen lock which is not re-entrant. The proper fix is to avoid patching inside the muslc linker as we do for Linux. Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
1 parent 725b967 commit 6fbadf7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/memray/_memray/elf_shenanigans.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ phdrs_callback(dl_phdr_info* info, [[maybe_unused]] size_t size, void* data) noe
171171
patched.insert(info->dlpi_name);
172172
}
173173

174-
if (strstr(info->dlpi_name, "/ld-linux") || strstr(info->dlpi_name, "linux-vdso.so.1")) {
174+
if (strstr(info->dlpi_name, "/ld-linux") || strstr(info->dlpi_name, "/ld-musl")
175+
|| strstr(info->dlpi_name, "linux-vdso.so.1"))
176+
{
175177
// Avoid chaos by not overwriting the symbols in the linker.
176178
// TODO: Don't override the symbols in our shared library!
177179
return 0;

0 commit comments

Comments
 (0)