Memory leak in libunbound?

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.

(attachments)

lu-test.c (1.22 KB)
lu-test.out (10.7 KB)

Hi Robert,

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