Maintained by: NLnet Labs

[Unbound-users] memory leak in libunbound?

Robert Edmonds
Sun Oct 2 04:26:39 CEST 2011


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.

-- 
Robert Edmonds
edmonds at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lu-test.c
Type: text/x-csrc
Size: 1246 bytes
Desc: not available
URL: <http://unbound.nlnetlabs.nl/pipermail/unbound-users/attachments/20111001/09238795/attachment.c>
-------------- next part --------------
==4015== Memcheck, a memory error detector
==4015== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==4015== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==4015== Command: ./lu-test www.debian.org
==4015== 
==4015== 
==4015== HEAP SUMMARY:
==4015==     in use at exit: 416 bytes in 6 blocks
==4015==   total heap usage: 3,311 allocs, 3,305 frees, 9,597,439 bytes allocated
==4015== 
==4015== 24 bytes in 1 blocks are still reachable in loss record 1 of 6
==4015==    at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4015==    by 0x5C2EB83: CRYPTO_malloc (mem.c:306)
==4015==    by 0x5C300D5: def_get_class (ex_data.c:308)
==4015==    by 0x5C30DDB: int_new_ex_data (ex_data.c:408)
==4015==    by 0x5C7C5E7: RSA_new_method (rsa_lib.c:185)
==4015==    by 0x54973A3: ldns_key_buf2rsa_raw (in /usr/lib/libldns.so.1.6.11)
==4015==    by 0x4E9CA59: dnskey_verify_rrset_sig (val_sigcrypt.c:1411)
==4015==    by 0x4E9DA1D: dnskey_verify_rrset (val_sigcrypt.c:641)
==4015==    by 0x4E9EB9F: val_verify_DNSKEY_with_TA.part.8 (val_utils.c:628)
==4015==    by 0x4E9F0F2: val_verify_new_DNSKEYs_with_ta (val_utils.c:666)
==4015==    by 0x4EA0BE7: val_inform_super (validator.c:2265)
==4015==    by 0x4E6AE6E: mesh_walk_supers (mesh.c:873)
==4015==    by 0x4E6BB3A: mesh_run (mesh.c:990)
==4015==    by 0x4E49231: libworker_handle_service_reply (libworker.c:757)
==4015==    by 0x4E6E160: serviced_callbacks (outside_network.c:1451)
==4015==    by 0x4E6F9C0: serviced_udp_callback (outside_network.c:1676)
==4015==    by 0x4E6F172: outnet_udp_cb (outside_network.c:439)
==4015==    by 0x4E86B98: comm_point_udp_callback (netevent.c:624)
==4015==    by 0x4E844CB: handle_select (mini_event.c:220)
==4015==    by 0x4E846C0: event_base_dispatch (mini_event.c:242)
==4015==    by 0x4E869DB: comm_base_dispatch (netevent.c:250)
==4015==    by 0x4E4AB07: libworker_fg (libworker.c:545)
==4015==    by 0x4E46F4C: ub_resolve (libunbound.c:572)
==4015==    by 0x4008B1: main (in /home/edmonds/code/test/lu-test)
==4015== 
==4015== 24 bytes in 1 blocks are still reachable in loss record 2 of 6
==4015==    at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4015==    by 0x5C2EB83: CRYPTO_malloc (mem.c:306)
==4015==    by 0x5C98C42: lh_insert (lhash.c:193)
==4015==    by 0x5C30107: def_get_class (ex_data.c:320)
==4015==    by 0x5C30DDB: int_new_ex_data (ex_data.c:408)
==4015==    by 0x5C7C5E7: RSA_new_method (rsa_lib.c:185)
==4015==    by 0x54973A3: ldns_key_buf2rsa_raw (in /usr/lib/libldns.so.1.6.11)
==4015==    by 0x4E9CA59: dnskey_verify_rrset_sig (val_sigcrypt.c:1411)
==4015==    by 0x4E9DA1D: dnskey_verify_rrset (val_sigcrypt.c:641)
==4015==    by 0x4E9EB9F: val_verify_DNSKEY_with_TA.part.8 (val_utils.c:628)
==4015==    by 0x4E9F0F2: val_verify_new_DNSKEYs_with_ta (val_utils.c:666)
==4015==    by 0x4EA0BE7: val_inform_super (validator.c:2265)
==4015==    by 0x4E6AE6E: mesh_walk_supers (mesh.c:873)
==4015==    by 0x4E6BB3A: mesh_run (mesh.c:990)
==4015==    by 0x4E49231: libworker_handle_service_reply (libworker.c:757)
==4015==    by 0x4E6E160: serviced_callbacks (outside_network.c:1451)
==4015==    by 0x4E6F9C0: serviced_udp_callback (outside_network.c:1676)
==4015==    by 0x4E6F172: outnet_udp_cb (outside_network.c:439)
==4015==    by 0x4E86B98: comm_point_udp_callback (netevent.c:624)
==4015==    by 0x4E844CB: handle_select (mini_event.c:220)
==4015==    by 0x4E846C0: event_base_dispatch (mini_event.c:242)
==4015==    by 0x4E869DB: comm_base_dispatch (netevent.c:250)
==4015==    by 0x4E4AB07: libworker_fg (libworker.c:545)
==4015==    by 0x4E46F4C: ub_resolve (libunbound.c:572)
==4015==    by 0x4008B1: main (in /home/edmonds/code/test/lu-test)
==4015== 
==4015== 32 bytes in 1 blocks are still reachable in loss record 3 of 6
==4015==    at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4015==    by 0x5C2EB83: CRYPTO_malloc (mem.c:306)
==4015==    by 0x5C9821E: sk_new (stack.c:125)
==4015==    by 0x5C300EB: def_get_class (ex_data.c:313)
==4015==    by 0x5C30DDB: int_new_ex_data (ex_data.c:408)
==4015==    by 0x5C7C5E7: RSA_new_method (rsa_lib.c:185)
==4015==    by 0x54973A3: ldns_key_buf2rsa_raw (in /usr/lib/libldns.so.1.6.11)
==4015==    by 0x4E9CA59: dnskey_verify_rrset_sig (val_sigcrypt.c:1411)
==4015==    by 0x4E9DA1D: dnskey_verify_rrset (val_sigcrypt.c:641)
==4015==    by 0x4E9EB9F: val_verify_DNSKEY_with_TA.part.8 (val_utils.c:628)
==4015==    by 0x4E9F0F2: val_verify_new_DNSKEYs_with_ta (val_utils.c:666)
==4015==    by 0x4EA0BE7: val_inform_super (validator.c:2265)
==4015==    by 0x4E6AE6E: mesh_walk_supers (mesh.c:873)
==4015==    by 0x4E6BB3A: mesh_run (mesh.c:990)
==4015==    by 0x4E49231: libworker_handle_service_reply (libworker.c:757)
==4015==    by 0x4E6E160: serviced_callbacks (outside_network.c:1451)
==4015==    by 0x4E6F9C0: serviced_udp_callback (outside_network.c:1676)
==4015==    by 0x4E6F172: outnet_udp_cb (outside_network.c:439)
==4015==    by 0x4E86B98: comm_point_udp_callback (netevent.c:624)
==4015==    by 0x4E844CB: handle_select (mini_event.c:220)
==4015==    by 0x4E846C0: event_base_dispatch (mini_event.c:242)
==4015==    by 0x4E869DB: comm_base_dispatch (netevent.c:250)
==4015==    by 0x4E4AB07: libworker_fg (libworker.c:545)
==4015==    by 0x4E46F4C: ub_resolve (libunbound.c:572)
==4015==    by 0x4008B1: main (in /home/edmonds/code/test/lu-test)
==4015== 
==4015== 32 bytes in 1 blocks are still reachable in loss record 4 of 6
==4015==    at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4015==    by 0x5C2EB83: CRYPTO_malloc (mem.c:306)
==4015==    by 0x5C9823C: sk_new (stack.c:127)
==4015==    by 0x5C300EB: def_get_class (ex_data.c:313)
==4015==    by 0x5C30DDB: int_new_ex_data (ex_data.c:408)
==4015==    by 0x5C7C5E7: RSA_new_method (rsa_lib.c:185)
==4015==    by 0x54973A3: ldns_key_buf2rsa_raw (in /usr/lib/libldns.so.1.6.11)
==4015==    by 0x4E9CA59: dnskey_verify_rrset_sig (val_sigcrypt.c:1411)
==4015==    by 0x4E9DA1D: dnskey_verify_rrset (val_sigcrypt.c:641)
==4015==    by 0x4E9EB9F: val_verify_DNSKEY_with_TA.part.8 (val_utils.c:628)
==4015==    by 0x4E9F0F2: val_verify_new_DNSKEYs_with_ta (val_utils.c:666)
==4015==    by 0x4EA0BE7: val_inform_super (validator.c:2265)
==4015==    by 0x4E6AE6E: mesh_walk_supers (mesh.c:873)
==4015==    by 0x4E6BB3A: mesh_run (mesh.c:990)
==4015==    by 0x4E49231: libworker_handle_service_reply (libworker.c:757)
==4015==    by 0x4E6E160: serviced_callbacks (outside_network.c:1451)
==4015==    by 0x4E6F9C0: serviced_udp_callback (outside_network.c:1676)
==4015==    by 0x4E6F172: outnet_udp_cb (outside_network.c:439)
==4015==    by 0x4E86B98: comm_point_udp_callback (netevent.c:624)
==4015==    by 0x4E844CB: handle_select (mini_event.c:220)
==4015==    by 0x4E846C0: event_base_dispatch (mini_event.c:242)
==4015==    by 0x4E869DB: comm_base_dispatch (netevent.c:250)
==4015==    by 0x4E4AB07: libworker_fg (libworker.c:545)
==4015==    by 0x4E46F4C: ub_resolve (libunbound.c:572)
==4015==    by 0x4008B1: main (in /home/edmonds/code/test/lu-test)
==4015== 
==4015== 128 bytes in 1 blocks are still reachable in loss record 5 of 6
==4015==    at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4015==    by 0x5C2EB83: CRYPTO_malloc (mem.c:306)
==4015==    by 0x5C988C1: lh_new (lhash.c:121)
==4015==    by 0x5C30172: def_get_class (ex_data.c:272)
==4015==    by 0x5C30DDB: int_new_ex_data (ex_data.c:408)
==4015==    by 0x5C7C5E7: RSA_new_method (rsa_lib.c:185)
==4015==    by 0x54973A3: ldns_key_buf2rsa_raw (in /usr/lib/libldns.so.1.6.11)
==4015==    by 0x4E9CA59: dnskey_verify_rrset_sig (val_sigcrypt.c:1411)
==4015==    by 0x4E9DA1D: dnskey_verify_rrset (val_sigcrypt.c:641)
==4015==    by 0x4E9EB9F: val_verify_DNSKEY_with_TA.part.8 (val_utils.c:628)
==4015==    by 0x4E9F0F2: val_verify_new_DNSKEYs_with_ta (val_utils.c:666)
==4015==    by 0x4EA0BE7: val_inform_super (validator.c:2265)
==4015==    by 0x4E6AE6E: mesh_walk_supers (mesh.c:873)
==4015==    by 0x4E6BB3A: mesh_run (mesh.c:990)
==4015==    by 0x4E49231: libworker_handle_service_reply (libworker.c:757)
==4015==    by 0x4E6E160: serviced_callbacks (outside_network.c:1451)
==4015==    by 0x4E6F9C0: serviced_udp_callback (outside_network.c:1676)
==4015==    by 0x4E6F172: outnet_udp_cb (outside_network.c:439)
==4015==    by 0x4E86B98: comm_point_udp_callback (netevent.c:624)
==4015==    by 0x4E844CB: handle_select (mini_event.c:220)
==4015==    by 0x4E846C0: event_base_dispatch (mini_event.c:242)
==4015==    by 0x4E869DB: comm_base_dispatch (netevent.c:250)
==4015==    by 0x4E4AB07: libworker_fg (libworker.c:545)
==4015==    by 0x4E46F4C: ub_resolve (libunbound.c:572)
==4015==    by 0x4008B1: main (in /home/edmonds/code/test/lu-test)
==4015== 
==4015== 176 bytes in 1 blocks are still reachable in loss record 6 of 6
==4015==    at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4015==    by 0x5C2EB83: CRYPTO_malloc (mem.c:306)
==4015==    by 0x5C9889F: lh_new (lhash.c:119)
==4015==    by 0x5C30172: def_get_class (ex_data.c:272)
==4015==    by 0x5C30DDB: int_new_ex_data (ex_data.c:408)
==4015==    by 0x5C7C5E7: RSA_new_method (rsa_lib.c:185)
==4015==    by 0x54973A3: ldns_key_buf2rsa_raw (in /usr/lib/libldns.so.1.6.11)
==4015==    by 0x4E9CA59: dnskey_verify_rrset_sig (val_sigcrypt.c:1411)
==4015==    by 0x4E9DA1D: dnskey_verify_rrset (val_sigcrypt.c:641)
==4015==    by 0x4E9EB9F: val_verify_DNSKEY_with_TA.part.8 (val_utils.c:628)
==4015==    by 0x4E9F0F2: val_verify_new_DNSKEYs_with_ta (val_utils.c:666)
==4015==    by 0x4EA0BE7: val_inform_super (validator.c:2265)
==4015==    by 0x4E6AE6E: mesh_walk_supers (mesh.c:873)
==4015==    by 0x4E6BB3A: mesh_run (mesh.c:990)
==4015==    by 0x4E49231: libworker_handle_service_reply (libworker.c:757)
==4015==    by 0x4E6E160: serviced_callbacks (outside_network.c:1451)
==4015==    by 0x4E6F9C0: serviced_udp_callback (outside_network.c:1676)
==4015==    by 0x4E6F172: outnet_udp_cb (outside_network.c:439)
==4015==    by 0x4E86B98: comm_point_udp_callback (netevent.c:624)
==4015==    by 0x4E844CB: handle_select (mini_event.c:220)
==4015==    by 0x4E846C0: event_base_dispatch (mini_event.c:242)
==4015==    by 0x4E869DB: comm_base_dispatch (netevent.c:250)
==4015==    by 0x4E4AB07: libworker_fg (libworker.c:545)
==4015==    by 0x4E46F4C: ub_resolve (libunbound.c:572)
==4015==    by 0x4008B1: main (in /home/edmonds/code/test/lu-test)
==4015== 
==4015== LEAK SUMMARY:
==4015==    definitely lost: 0 bytes in 0 blocks
==4015==    indirectly lost: 0 bytes in 0 blocks
==4015==      possibly lost: 0 bytes in 0 blocks
==4015==    still reachable: 416 bytes in 6 blocks
==4015==         suppressed: 0 bytes in 0 blocks
==4015== 
==4015== For counts of detected and suppressed errors, rerun with: -v
==4015== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)