From 515821cbcbfe6f3a3f9e7b8cded31442fb7b413f Mon Sep 17 00:00:00 2001 From: AdamBEKKAR Date: Wed, 8 Jul 2026 16:06:35 +0200 Subject: [PATCH] Fix pthread_create self-recursion on glibc >= 2.34 Resolve pthread_create/join/kill via RTLD_NEXT instead of dlopen(libpthread.so.0, RTLD_NOLOAD), which returns NULL on glibc >= 2.34 (pthread merged into libc.so.6), causing dlsym(NULL, ...) to resolve back to this library's own interposed pthread_create and recurse infinitely. --- source/real.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source/real.cpp b/source/real.cpp index 8320fc2..3ba7196 100644 --- a/source/real.cpp +++ b/source/real.cpp @@ -43,10 +43,8 @@ namespace Real { INIT_WRAPPER(calloc, RTLD_NEXT); INIT_WRAPPER(realloc, RTLD_NEXT); - // FIXME about the flags - void *pthread_handle = dlopen("libpthread.so.0", RTLD_NOW | RTLD_GLOBAL | RTLD_NOLOAD); - INIT_WRAPPER(pthread_create, pthread_handle); - INIT_WRAPPER(pthread_join, pthread_handle); - INIT_WRAPPER(pthread_kill, pthread_handle); + INIT_WRAPPER(pthread_create, RTLD_NEXT); + INIT_WRAPPER(pthread_join, RTLD_NEXT); + INIT_WRAPPER(pthread_kill, RTLD_NEXT); } }