memory leak

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

memory leak

Sébastien Paumier
Hi,
I use libcurl in a project on linux and valgrind reports memory leaks in libnspr4.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 like _pr_clock_lm that are initialized in _PR_InitStuff but without any obvious corresponding deallocations. I also found this comment later in the same 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ébastien Paumier

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

*** No errors detected
==878==
==878== HEAP SUMMARY:
==878==     in use at exit: 6,824 bytes in 69 blocks
==878==   total heap usage: 35,679 allocs, 35,610 frees, 4,828,690 bytes allocated
==878==
==878== 3 bytes in 1 blocks are still reachable in loss record 1 of 62
==878==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==878==    by 0x351FC80E91: strdup (in /lib64/libc-2.12.so)
==878==    by 0x352E410A14: PR_NewLogModule (in /lib64/libnspr4.so)
==878==    by 0x352E41AE4D: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 3 bytes in 1 blocks are still reachable in loss record 3 of 62
==878==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==878==    by 0x352E4162FC: PR_CreateStack (in /lib64/libnspr4.so)
==878==    by 0x352E40D30A: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E428A7F: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E41AF48: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 6 bytes in 1 blocks are still reachable in loss record 11 of 62
==878==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==878==    by 0x352E415283: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E41AF5E: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 24 bytes in 1 blocks are still reachable in loss record 27 of 62
==878==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==878==    by 0x352E40E71E: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E41AF84: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 24 bytes in 1 blocks are still reachable in loss record 28 of 62
==878==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==878==    by 0x352E41A61A: PR_ErrorInstallTable (in /lib64/libnspr4.so)
==878==    by 0x352E41AF8E: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 32 bytes in 1 blocks are still reachable in loss record 29 of 62
==878==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==878==    by 0x351F80130F: _dlerror_run (in /lib64/libdl-2.12.so)
==878==    by 0x351F800EE0: dlopen@@GLIBC_2.2.5 (in /lib64/libdl-2.12.so)
==878==    by 0x352E415B73: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E41AE16: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 40 bytes in 1 blocks are still reachable in loss record 30 of 62
==878==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==878==    by 0x352E40D60B: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E425094: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E428A92: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E41AF48: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 64 bytes in 1 blocks are still reachable in loss record 37 of 62
==878==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==878==    by 0x352E42329A: PR_NewCondVar (in /lib64/libnspr4.so)
==878==    by 0x352E428FC0: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E41AF39: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 168 bytes in 1 blocks are still reachable in loss record 41 of 62
==878==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==878==    by 0x352E423FCC: PR_NewLock (in /lib64/libnspr4.so)
==878==    by 0x352E41A338: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E41AF14: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878== 168 bytes in 1 blocks are still reachable in loss record 53 of 62
==878==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==878==    by 0x352E423E99: PR_NewMonitor (in /lib64/libnspr4.so)
==878==    by 0x352E423F98: PR_NewNamedMonitor (in /lib64/libnspr4.so)
==878==    by 0x352E41531B: ??? (in /lib64/libnspr4.so)
==878==    by 0x352E41AF5E: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878==
==878== 168 bytes in 1 blocks are still reachable in loss record 59 of 62
==878==    at 0x4A0577B: calloc (vg_replace_malloc.c:593)
==878==    by 0x352E423E99: PR_NewMonitor (in /lib64/libnspr4.so)
==878==    by 0x352E42AA10: ??? (in /lib64/libnspr4.so)
==878==    by 0x3537040348: Curl_nss_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x353702CCD8: curl_global_init (in /usr/lib64/libcurl.so.4.1.1)
==878==    by 0x4BDDA9: ...
==878==
==878==
==878== LEAK SUMMARY:
==878==    definitely lost: 0 bytes in 0 blocks
==878==    indirectly lost: 0 bytes in 0 blocks
==878==      possibly lost: 0 bytes in 0 blocks
==878==    still reachable: 6,824 bytes in 69 blocks
==878==         suppressed: 0 bytes in 0 blocks
==878==
==878== For counts of detected and suppressed errors, rerun with: -v
==878== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
_______________________________________________
dev-tech-nspr mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-nspr