diff --git a/build-bench-env.sh b/build-bench-env.sh index 9b98cc4..3701b7c 100755 --- a/build-bench-env.sh +++ b/build-bench-env.sh @@ -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 diff --git a/patches/gd.patch b/patches/gd.patch new file mode 100644 index 0000000..93322ba --- /dev/null +++ b/patches/gd.patch @@ -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);