[Unbound-users] memory leak in libunbound?

W.C.A. Wijngaards wouter at NLnetLabs.nl
Mon Oct 10 10:33:24 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Robert,

On 10/02/2011 04:26 AM, Robert Edmonds wrote:
> hi,
> 
> am i using the libunbound API incorrectly or is there a memory leak in
> libunbound?  i have written a simple test case that simply does,
> roughly:
> 
>     ub_ctx_create()
>     ub_ctx_resolvconf()
>     ub_ctx_add_ta()
>     ub_resolve()
>     ub_resolve_free()
>     ub_ctx_delete()
> 
> attached is the test case and the output from running it on a signed
> domain.

There is no leak from my knowledge, and I tested it.

What you see is a number of statical allocations from libssl, where it
sets up method pointers and other generic structures.  These could be
freed on exit of your program, by calling a number of SSL cleanup
routines.  However, the library libunbound cannot possibly do this,
because that would impact the libssl global state, and it should allow
the app to use libssl itself.

So, if you do it in a loop of 100000 times, the leak does not grow, this
is global allocations from libssl.  It is initializing stuff on the
first call to RSA_x().

So, I think you are running into openssl peculiarities here.  If it does
grow when you do multiple iterations or its not cleaned when you cleanup
ssl on exit (which is very hard and impossible, this cleanup), then you
catch a real leak.

Best regards,
   Wouter
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOksn0AAoJEJ9vHC1+BF+N3jYQAJIVXQ8kZ855Kq8yAf0SlzDH
MkZcFP2o7H1CWYA/GKomVvy4QBxLfpe1wEpo9UVkeHYa2xDW++lbJFZwrvoPBJhm
/NwHeLg1wDvmA6tYZVLOLUGRlkt2PN7iD4OGHgCP8yddCEUpQUfBDGbQwIzVDFPv
6J3IszTw8f3wvibxr50Y6bmU438XkUGxd7g9WDl10IpCsCj2S23SrWqgRaDLZ2xu
gZswrTb1bvX3ILyUFa2z94yR5874ObT2A2lkmBai1iWtOCDtjkxVk6jFLpRAEndg
0mddAHE0O8/AQApC0oBrrvyTgTIeB9d61SqOaTuutY+mXARXvyqM8M+Y1KEeZAxw
f21TdjQnqv1q11PZOJzAa6SEC1bVPd70Mu4qwjbt0tA+v9V2YzDdLo9HaShPKVs7
c/ogf1gSJo6NZk7hn6sZxBjaf77gEdU8Lfr0xGPBrdWhc5HLCexj6fyXUGxYFjZJ
ITMjxnisrRnU1XXlHRZa9YZHfr/iGfE3Rijk/egLdZfYtjj5F7UlDkt/B+zivK9/
eGfF7oUULfsFM3vG163LhobZOhZeuz6+0R/ZoEyOkgDLtfvt2YC+gv+XQTa5zLGw
iTxuF7SyXu/fQqGvHlcIiqPaCLHMHIB1uy7eqBLuUxnEiuHFOZTDk+rFTwIFKaXY
FxPr4nbzrS/woA1vFXVu
=RKM4
-----END PGP SIGNATURE-----



More information about the Unbound-users mailing list