Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build-bench-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ fi

if test "$setup_gd" = "1"; then
checkout gd $version_gd https://github.com/UTSASRG/Guarder
set +e
patch -p1 -N -r- < ../../patches/gd.patch
set -e
make -j $procs
popd
fi
Expand Down
19 changes: 19 additions & 0 deletions patches/gd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/real.cpp
+++ b/real.cpp
@@ -43,8 +43,15 @@
INIT_WRAPPER(malloc, RTLD_NEXT);
// INIT_WRAPPER(realloc, RTLD_NEXT);

- // FIXME about the flags
+ // glibc >= 2.34 moved pthread into libc; libpthread.so.0 is an empty
+ // compatibility stub that nothing loads any more, so this dlopen returns
+ // NULL. dlsym(NULL, name) is dlsym(RTLD_DEFAULT, name), which searches the
+ // preloaded libraries first and would hand us back our own interposers
+ // below, making every thread creation recurse into itself. RTLD_NEXT
+ // starts the search after libguarder, i.e. at the real libc.
void *pthread_handle = dlopen("libpthread.so.0", RTLD_NOW | RTLD_GLOBAL | RTLD_NOLOAD);
+ if (pthread_handle == NULL)
+ pthread_handle = RTLD_NEXT;
INIT_WRAPPER(pthread_create, pthread_handle);
INIT_WRAPPER(pthread_join, pthread_handle);
INIT_WRAPPER(pthread_kill, pthread_handle);
Loading