UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » General
  • » Does Openssl have a cleanup function make valgrind happy

#1 2010-06-27 11:27 AM

xinglp
Member
Registered: 2008-04-13
Posts: 35

Re: Does Openssl have a cleanup function make valgrind happy

openssl was configed by -DPURIFY . valgrind  stil report below

==300== HEAP SUMMARY:
==300==     in use at exit: 1,044 bytes in 13 blocks
==300==   total heap usage: 24,386 allocs, 24,373 frees, 42,513,173 bytes allocated
==300==
==300== 17 bytes in 1 blocks are still reachable in loss record 1 of 6
==300==    at 0x40264F2: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==300==    by 0x40089F6: _dl_map_object (in /lib/ld-2.11.2.so)
==300==    by 0x40136C1: dl_open_worker (in /lib/ld-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x4013F77: _dl_open (in /lib/ld-2.11.2.so)
==300==    by 0x4323B7B: dlopen_doit (in /lib/libdl-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x432430C: _dlerror_run (in /lib/libdl-2.11.2.so)
==300==    by 0x4323C31: [email protected]@GLIBC_2.1 (in /lib/libdl-2.11.2.so)
==300==    by 0x42692D9: dlfcn_load (in /usr/lib/libcrypto.so.0.9.8)
==300==
==300== 17 bytes in 1 blocks are still reachable in loss record 2 of 6
==300==    at 0x40264F2: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==300==    by 0x400B4DF: _dl_new_object (in /lib/ld-2.11.2.so)
==300==    by 0x4006907: _dl_map_object_from_fd (in /lib/ld-2.11.2.so)
==300==    by 0x400877F: _dl_map_object (in /lib/ld-2.11.2.so)
==300==    by 0x40136C1: dl_open_worker (in /lib/ld-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x4013F77: _dl_open (in /lib/ld-2.11.2.so)
==300==    by 0x4323B7B: dlopen_doit (in /lib/libdl-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x432430C: _dlerror_run (in /lib/libdl-2.11.2.so)
==300==    by 0x4323C31: [email protected]@GLIBC_2.1 (in /lib/libdl-2.11.2.so)
==300==    by 0x42692D9: dlfcn_load (in /usr/lib/libcrypto.so.0.9.8)
==300==
==300== 28 bytes in 1 blocks are still reachable in loss record 3 of 6
==300==    at 0x40264F2: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==300==    by 0x400DD7C: _dl_map_object_deps (in /lib/ld-2.11.2.so)
==300==    by 0x401371C: dl_open_worker (in /lib/ld-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x4013F77: _dl_open (in /lib/ld-2.11.2.so)
==300==    by 0x4323B7B: dlopen_doit (in /lib/libdl-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x432430C: _dlerror_run (in /lib/libdl-2.11.2.so)
==300==    by 0x4323C31: [email protected]@GLIBC_2.1 (in /lib/libdl-2.11.2.so)
==300==    by 0x42692D9: dlfcn_load (in /usr/lib/libcrypto.so.0.9.8)
==300==
==300== 134 bytes in 8 blocks are still reachable in loss record 4 of 6
==300==    at 0x40264F2: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==300==    by 0x421070B: default_malloc_ex (in /usr/lib/libcrypto.so.0.9.8)
==300==
==300== 224 bytes in 1 blocks are still reachable in loss record 5 of 6
==300==    at 0x4024FA3: calloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==300==    by 0x4010BA8: _dl_check_map_versions (in /lib/ld-2.11.2.so)
==300==    by 0x4013990: dl_open_worker (in /lib/ld-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x4013F77: _dl_open (in /lib/ld-2.11.2.so)
==300==    by 0x4323B7B: dlopen_doit (in /lib/libdl-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x432430C: _dlerror_run (in /lib/libdl-2.11.2.so)
==300==    by 0x4323C31: [email protected]@GLIBC_2.1 (in /lib/libdl-2.11.2.so)
==300==    by 0x42692D9: dlfcn_load (in /usr/lib/libcrypto.so.0.9.8)
==300==
==300== 624 bytes in 1 blocks are still reachable in loss record 6 of 6
==300==    at 0x4024FA3: calloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==300==    by 0x400B231: _dl_new_object (in /lib/ld-2.11.2.so)
==300==    by 0x4006907: _dl_map_object_from_fd (in /lib/ld-2.11.2.so)
==300==    by 0x400877F: _dl_map_object (in /lib/ld-2.11.2.so)
==300==    by 0x40136C1: dl_open_worker (in /lib/ld-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x4013F77: _dl_open (in /lib/ld-2.11.2.so)
==300==    by 0x4323B7B: dlopen_doit (in /lib/libdl-2.11.2.so)
==300==    by 0x400F3C6: _dl_catch_error (in /lib/ld-2.11.2.so)
==300==    by 0x432430C: _dlerror_run (in /lib/libdl-2.11.2.so)
==300==    by 0x4323C31: [email protected]@GLIBC_2.1 (in /lib/libdl-2.11.2.so)
==300==    by 0x42692D9: dlfcn_load (in /usr/lib/libcrypto.so.0.9.8)
==300==
==300== LEAK SUMMARY:
==300==    definitely lost: 0 bytes in 0 blocks
==300==    indirectly lost: 0 bytes in 0 blocks
==300==      possibly lost: 0 bytes in 0 blocks
==300==    still reachable: 1,044 bytes in 13 blocks
==300==         suppressed: 0 bytes in 0 blocks
==300==
==300== For counts of detected and suppressed errors, rerun with: -v
==300== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 24 from 11)

Offline

#2 2010-06-27 02:23 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Does Openssl have a cleanup function make valgrind happy

Don't worry about it.

Offline

#3 2010-06-27 05:01 PM

xinglp
Member
Registered: 2008-04-13
Posts: 35

Re: Does Openssl have a cleanup function make valgrind happy

This can not be fixed?

Offline

#4 2010-06-27 07:06 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Does Openssl have a cleanup function make valgrind happy

Yes, it can be "fixed", but it's not worth the trouble, because it's not a real problem.

Offline

#5 2010-06-28 12:35 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Does Openssl have a cleanup function make valgrind happy

Yeah, about the only thing you should really care about in valgrind's leak stats is
the "definitely lost" section...  Those generally indicate real leaks that you should
probably find and fix...  The rest are usually nothing wrong at all, and simply indicate
memory that wasn't explicitly freed at exit time...  And, really, what's the point of
explicitly freeing all your memory at exit time?  It's not required at all...  Any OS worth
a damn will take care of that for you at exit time...

Offline

#6 2010-06-28 02:06 PM

xinglp
Member
Registered: 2008-04-13
Posts: 35

Re: Does Openssl have a cleanup function make valgrind happy

Offline

#7 2010-06-28 04:36 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Does Openssl have a cleanup function make valgrind happy

Well, it looks like dlopen() allocates memory which is never or partially freed.
dclose() probably frees up almost all of it, but I can imagine that dlopen()
constructs some data structure with loaded library information which is kept
around even if all loaded libs are closed. Think

...
if (!libs)
	libs = malloc(sizeof(struct libs));
...


Your example allocated 45 megabtes of memory, and just kept 1 kilobyte around.
I bet that number doesn't increase much, if any, if your program allocated more
memory during its lifetime. It's not a memory leak, it's not a bug, it's only bugging
you because Valgrind shows you that info.

My advise is to ignore all Valgrind output not related to your own code.

If you want to "fix" this then read glibc's source code, write a patch, and send
it to their mailinglist or something. But you would have wasted your time on
"fixing" something that's not a real bug.

Offline

#8 2010-06-28 07:49 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Does Openssl have a cleanup function make valgrind happy

Offline

#9 2010-06-28 10:35 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Does Openssl have a cleanup function make valgrind happy

Offline

#10 2010-06-29 02:52 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Does Openssl have a cleanup function make valgrind happy

Offline

  • Index
  • » General
  • » Does Openssl have a cleanup function make valgrind happy

Board footer

Powered by FluxBB