]> 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>
Thu, 28 Oct 2004 08:16:38 +0000 (08:16 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 28 Oct 2004 08:16:38 +0000 (08:16 +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.

MERGED FROM HEAD

git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_2_2_0_BRANCH@2865

coregrind/vg_libpthread.c

index 308cadb0e7e2222362a0e9fc02c5b549ddb0b29d..e54650136dc6d4947546b2d39e5b21f5f2ef9d43 100644 (file)
@@ -2242,13 +2242,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); \
   })