[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    VALGRIND_2_2_0_BRANCH: valgrind/coregrind
From:       Tom Hughes <thh () cyberscience ! com>
Date:       2004-10-28 8:16:38
Message-ID: 20041028081638.BCE2216C4F () office ! kde ! org
[Download RAW message or body]

CVS commit by thughes: 

Yet another attempt to quash the assertions in the pthread forwarding code.

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


  M +7 -1      vg_libpthread.c   1.161.2.2


--- valgrind/coregrind/vg_libpthread.c  #1.161.2.1:1.161.2.2
@@ -2243,11 +2243,17 @@ void ** (*__libc_internal_tsd_address) 
    ------------------------------------------------------------------ */
 
+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); \


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic