This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug dynamic-link/21427] New: Leak memory in dlsym(), and take double library files


https://sourceware.org/bugzilla/show_bug.cgi?id=21427

            Bug ID: 21427
           Summary: Leak memory in dlsym(), and take double library files
           Product: glibc
           Version: 2.25
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: rmbeer2 at gmail dot com
  Target Milestone: ---

I use Archlinux, and 32 bits of system.

Have a error of Leak Memory in the dlsym, also dlsym(0,"") and dlsym(hnd,"")
take the two library in the different memory where i use RTLD_NOLOAD.

This is the code of main.cpp with the result of Valgrind:


#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <allegro5/allegro.h>

int main(int argc, char *argv[]){
  //void*hnd=dlopen("/usr/lib/liballegro.so",RTLD_NOW|RTLD_GLOBAL|RTLD_NOLOAD);
  void*hnd=dlopen("liballegro.so",RTLD_NOW|RTLD_GLOBAL|RTLD_NOLOAD);
 
//void*hnd=dlopen("/usr/lib/liballegro.so.5.2.2",RTLD_NOW|RTLD_GLOBAL|RTLD_NOLOAD);
  printf("HND:%p (DEFAULT:%d)\n",hnd,RTLD_DEFAULT);
  if(!hnd){printf("fopen\n");return -1;}
  void*p=dlsym(0,"al_translate_transform");
  void*p2=dlsym(hnd,"al_translate_transform");
  void*p3=dlsym(RTLD_DEFAULT,"al_translate_transform");
  printf("Cargado\n");
  printf("P:%p P2:%p P3:%p\n",p,p2,p3);
  printf("%p\n",al_translate_transform);
  dlclose(hnd);
  return 0;
}

/*
HND:0xb777a520 (DEFAULT:0)
Cargado
P:0x80484d0 P2:0xb76a0250 P3:0x80484d0
0x80484d0

VALGRIND:
 20 bytes in 1 blocks are still reachable in loss record 1 of 1
    at 0x402F586: calloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
    by 0x416F4BB: ??? (in /usr/lib/libdl-2.25.so)
    by 0x416EE55: dlsym (in /usr/lib/libdl-2.25.so)
    by 0x47BB280: ??? (in /usr/lib/libGLdispatch.so.0.0.0)
    by 0x47B86C3: ??? (in /usr/lib/libGLdispatch.so.0.0.0)
    by 0x400F1E4: call_init.part.0 (in /usr/lib/ld-2.25.so)
    by 0x400F30D: _dl_init (in /usr/lib/ld-2.25.so)
    by 0x4000C0E: ??? (in /usr/lib/ld-2.25.so)
 */

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]