Hi folks!

I'm looking at memory leaks, starting with the simple test program

#include <ssl.h>
#include <stdio.h>
int main()
{
        NSS_NoDB_Init();
        NSS_Shutdown();
}

This shows two leaks right now, but should show none, right?

The first leak was mentioned by wtc in
http://sources.redhat.com/bugzilla/show_bug.cgi?id=2451
and shows up for me like this:

4 bytes in 1 blocks are definitely lost in loss record 1 of 6
   at malloc (vg_replace_malloc.c:207)
   by _dl_map_object_from_fd (in /lib32/ld-2.8.90.so)
...
   by dlopen@@GLIBC_2.1 (in /lib32/libdl-2.8.90.so)
   by pr_LoadLibraryByPathname (prlink.c:984)
   by PR_LoadLibraryWithFlags (prlink.c:580)
   by ???
   by ???
...
   by secmod_ModuleInit (pk11load.c:147)
   by SECMOD_LoadPKCS11Module (pk11load.c:379)
   by SECMOD_LoadModule (pk11pars.c:323)
   by SECMOD_LoadModule (pk11pars.c:338)
   by nss_Init (nssinit.c:541)

(Side question: how did Wan-Teh get that nice backtrace?  I'm
missing some of the symbols, possibly because they're in a loaded
module.  I tried building and running with a local copy of nss per
http://code.google.com/p/chromium/wiki/LinuxDebuggingSSL
and even tried referencing the fips module's directory like this:
$ gcc -g -O0 -I /usr/include/nss -I /usr/include/nspr foo.c -L/home/
dank/nss-3.12/mozilla/dist/Linux2.6_x86_glibc_PTH_DBG.OBJ/lib -L $HOME/
nss-3.12/mozilla/security/nss/lib/freebl/
Linux2.6_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB -m32 -lnss3
$ LD_LIBRARY_PATH=/home/dank/nss-3.12/mozilla/dist/
Linux2.6_x86_glibc_PTH_DBG.OBJ/lib:$HOME/nss-3.12/mozilla/security/nss/
lib/freebl/Linux2.6_x86_glibc_PTH_DBG.OBJ/Linux_SINGLE_SHLIB valgrind
--leak-check=full --num-callers=30 ./a.out
but still no symbols for part of the backtrace.)

The second leak is:

72 bytes in 1 blocks are definitely lost in loss record 4 of 6
   at calloc (vg_replace_malloc.c:397)
   by PR_Calloc (prmem.c:474)
   by error_get_my_stack (error.c:141)
   by nss_ClearErrorStack (error.c:277)
   by NSSArena_Create (arena.c:385)
   by NSSTrustDomain_Create (trustdomain.c:74)
   by STAN_LoadDefaultNSS3TrustDomain (pki3hack.c:141)
   by nss_Init (nssinit.c:553)
   by NSS_NoDB_Init (nssinit.c:700)
   by main (foo.c:7)

This is odd, as STAN_Shutdown pretty clearly tries to free the default
trust domain.

For the moment, I'll probably just add these to our suppressions file,
but
it'd be nice to know what's going on.
- Dan
-- 
dev-tech-crypto mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to