]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Yet another attempt to quash the assertions in the pthread forwarding code.
authorTom Hughes <tom@compton.nu>
Sat, 16 Oct 2004 10:50:11 +0000 (10:50 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 16 Oct 2004 10:50:11 +0000 (10:50 +0000)
It appears that the resolution of the address is to forward to is now
working properly but that on some systems the second part of the assertion
fails because the dynamic linker resolves the name of the function being
forwarded to the glibc version rather than the version in valgrind's pthread
library.

The solution is to use dlopen to explicitly obtain a handle to valgrind's
pthread library and then lookup the symbol with dlsym when doing the
comparison in the assertion.

BUG: 88614

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2772

coregrind/vg_libpthread.c

index b8f8e7eb4f948b3156cad0fb1f51a88fcd0f0c55..997096e27a4de79ebd3df0e05d32b68666332a93 100644 (file)
@@ -2252,13 +2252,19 @@ void ** (*__libc_internal_tsd_address)
    to the corresponding thread-unaware (?) libc routine.
    ------------------------------------------------------------------ */
 
+static void *libpthread_handle;
+
 #define FORWARD(name, altname, args...) \
   ({ \
     static name##_t name##_ptr = NULL; \
+    if (libpthread_handle == NULL) { \
+      libpthread_handle = dlopen("libpthread.so.0", RTLD_LAZY); \
+      my_assert(libpthread_handle != NULL); \
+    } \
     if (name##_ptr == NULL) { \
       if ((name##_ptr = (name##_t)dlsym(RTLD_NEXT, #name)) == NULL) \
         name##_ptr = (name##_t)dlsym(RTLD_DEFAULT, #altname); \
-      my_assert(name##_ptr != NULL && name##_ptr != name); \
+      my_assert(name##_ptr != NULL && name##_ptr != dlsym(libpthread_handle, #name)); \
     } \
     name##_ptr(args); \
   })