tags 700899 + pending - patch
kthxbye

On lun, feb 18, 2013 at 05:30:54 -0500, Daniel Kahn Gillmor wrote:
> Package: valgrind
> Version: 1:3.8.1-1
> Severity: normal
> Tags: patch
> 
> If i link the simple program below with -lpthread, then valgrind
> reports a block of 32 bytes still-reachable from calloc within
> dlopen().
> 
> If i do not link with -lpthread, then valgrind reports no errors.

I've looked a bit into this, and it seems that the _dlerror_run() function
allocates a thread specific buffer which gets automatically freed once the
thread terminates. In fact when calling dlopen()/dlclose() inside a thread the
leak does not happen:

  #include <dlfcn.h>
  #include <pthread.h>

  void *leak(void *a) {
        void *x;

        x = dlopen("/usr/lib/x86_64-linux-gnu/libm.so", RTLD_LOCAL | RTLD_NOW);
        dlclose(x);
  }

  int main(int argc, char *argv[]) {
        pthread_t t;
        void *ret;

        pthread_create(&t, NULL, leak, NULL);
        pthread_join(t, &ret);

        /* leak(NULL); */

        return 0;
  }

It seems a benign leak so adding a suppression shouldn't cause any problem. This
is the suppression I've added (yours is a little bit too specific):

  {
    dlopen() with -lpthread bug#700899
    Memcheck:Leak
    fun:calloc
    fun:_dlerror_run
    fun:dlopen@@GLIBC_2.2.5
  }

Cheers

-- 
perl -E '$_=q;$/= @{[@_]};and s;\S+;<inidehG ordnasselA>;eg;say~~reverse'

Attachment: signature.asc
Description: Digital signature

Reply via email to