memory leak

Sébastien Paumier <[email protected]> Tue, 16 Sep 2014 23:45:04 -0700 (PDT)
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
Hi,
I use libcurl in a project on linux and valgrind reports memory leaks in li=
bnspr4.so, even if libcurl's cleanup code is invoked. Below is the summary =
of problems pointing to libnspr4 (I removed duplicates for clarity).

I use nspr 4.10.6 on Centos 6.5 64 bits.

I looked at nspr's source code and found that there are several variables l=
ike _pr_clock_lm that are initialized in _PR_InitStuff but without any obvi=
ous corresponding deallocations. I also found this comment later in the sam=
e file prinit.c:

        /*
         * XXX: We are freeing the heap memory here so that Purify won't
         * complain, but we should also free other kinds of resources
         * that are allocated by the _PR_InitXXX() functions.
         * Ideally, for each _PR_InitXXX(), there should be a corresponding
         * _PR_XXXCleanup() that we can call here.
         */

It seems that this is the same issue as reported here in 2009:

http://curl.haxx.se/mail/lib-2009-04/0170.html

It would be very nice if these problems could be fixed.

Best regards,
S=E9bastien Paumier

=3D=3D878=3D=3D Memcheck, a memory error detector
=3D=3D878=3D=3D Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et=
 al.
=3D=3D878=3D=3D Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyrigh=
t info
=3D=3D878=3D=3D Command: /home/sep/nle/build/frameworks/appcomm/tests/appco=
mm_test
=3D=3D878=3D=3D =


*** No errors detected
=3D=3D878=3D=3D =

=3D=3D878=3D=3D HEAP SUMMARY:
=3D=3D878=3D=3D     in use at exit: 6,824 bytes in 69 blocks
=3D=3D878=3D=3D   total heap usage: 35,679 allocs, 35,610 frees, 4,828,690 =
bytes allocated
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 3 bytes in 1 blocks are still reachable in loss record 1 of=
 62
=3D=3D878=3D=3D    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
=3D=3D878=3D=3D    by 0x351FC80E91: strdup (in /lib64/libc-2.12.so)
=3D=3D878=3D=3D    by 0x352E410A14: PR_NewLogModule (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AE4D: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 3 bytes in 1 blocks are still reachable in loss record 3 of=
 62
=3D=3D878=3D=3D    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
=3D=3D878=3D=3D    by 0x352E4162FC: PR_CreateStack (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E40D30A: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E428A7F: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AF48: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 6 bytes in 1 blocks are still reachable in loss record 11 o=
f 62
=3D=3D878=3D=3D    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
=3D=3D878=3D=3D    by 0x352E415283: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AF5E: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 24 bytes in 1 blocks are still reachable in loss record 27 =
of 62
=3D=3D878=3D=3D    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
=3D=3D878=3D=3D    by 0x352E40E71E: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AF84: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 24 bytes in 1 blocks are still reachable in loss record 28 =
of 62
=3D=3D878=3D=3D    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
=3D=3D878=3D=3D    by 0x352E41A61A: PR_ErrorInstallTable (in /lib64/libnspr=
4.so)
=3D=3D878=3D=3D    by 0x352E41AF8E: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 32 bytes in 1 blocks are still reachable in loss record 29 =
of 62
=3D=3D878=3D=3D    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
=3D=3D878=3D=3D    by 0x351F80130F: _dlerror_run (in /lib64/libdl-2.12.so)
=3D=3D878=3D=3D    by 0x351F800EE0: dlopen@@GLIBC_2.2.5 (in /lib64/libdl-2.=
12.so)
=3D=3D878=3D=3D    by 0x352E415B73: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AE16: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 40 bytes in 1 blocks are still reachable in loss record 30 =
of 62
=3D=3D878=3D=3D    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
=3D=3D878=3D=3D    by 0x352E40D60B: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E425094: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E428A92: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AF48: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 64 bytes in 1 blocks are still reachable in loss record 37 =
of 62
=3D=3D878=3D=3D    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
=3D=3D878=3D=3D    by 0x352E42329A: PR_NewCondVar (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E428FC0: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AF39: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 168 bytes in 1 blocks are still reachable in loss record 41=
 of 62
=3D=3D878=3D=3D    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
=3D=3D878=3D=3D    by 0x352E423FCC: PR_NewLock (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41A338: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AF14: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D 168 bytes in 1 blocks are still reachable in loss record 53=
 of 62
=3D=3D878=3D=3D    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
=3D=3D878=3D=3D    by 0x352E423E99: PR_NewMonitor (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E423F98: PR_NewNamedMonitor (in /lib64/libnspr4.=
so)
=3D=3D878=3D=3D    by 0x352E41531B: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E41AF5E: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D =

=3D=3D878=3D=3D 168 bytes in 1 blocks are still reachable in loss record 59=
 of 62
=3D=3D878=3D=3D    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
=3D=3D878=3D=3D    by 0x352E423E99: PR_NewMonitor (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x352E42AA10: ??? (in /lib64/libnspr4.so)
=3D=3D878=3D=3D    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so=
.4.1.1)
=3D=3D878=3D=3D    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl=
.so.4.1.1)
=3D=3D878=3D=3D    by 0x4BDDA9: ...
=3D=3D878=3D=3D =

=3D=3D878=3D=3D =

=3D=3D878=3D=3D LEAK SUMMARY:
=3D=3D878=3D=3D    definitely lost: 0 bytes in 0 blocks
=3D=3D878=3D=3D    indirectly lost: 0 bytes in 0 blocks
=3D=3D878=3D=3D      possibly lost: 0 bytes in 0 blocks
=3D=3D878=3D=3D    still reachable: 6,824 bytes in 69 blocks
=3D=3D878=3D=3D         suppressed: 0 bytes in 0 blocks
=3D=3D878=3D=3D =

=3D=3D878=3D=3D For counts of detected and suppressed errors, rerun with: -v
=3D=3D878=3D=3D ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from=
 6)