From: Tom Hughes Date: Thu, 28 Oct 2004 08:16:38 +0000 (+0000) Subject: Yet another attempt to quash the assertions in the pthread forwarding code. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2865b47d86f6a614d1575beddc52c0f95352a8da;p=thirdparty%2Fvalgrind.git 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 git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_2_2_0_BRANCH@2865 --- diff --git a/coregrind/vg_libpthread.c b/coregrind/vg_libpthread.c index 308cadb0e7..e54650136d 100644 --- a/coregrind/vg_libpthread.c +++ b/coregrind/vg_libpthread.c @@ -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); \ })