memory leak in main
I can more-or-less reliably reproduce following crash:
D:rrl:Core was generated by `/home/ondrej/Projects/bind9/bin/named/.libs/named -D rrl-ns2 -X named.lock -m r'.
D:rrl:Program terminated with signal SIGABRT, Aborted.
D:rrl:#0 0x00007fdc2dd8e7bb in raise () from /lib/x86_64-linux-gnu/libc.so.6
D:rrl:#0 0x00007fdc2dd8e7bb in raise () from /lib/x86_64-linux-gnu/libc.so.6
D:rrl:#1 0x00007fdc2dd79535 in abort () from /lib/x86_64-linux-gnu/libc.so.6
D:rrl:#2 0x000055dc9eb46c2f in assertion_failed (file=<optimized out>, line=<optimized out>, type=isc_assertiontype_insist, cond=0x7fdc2ea7aa97 "malloced == 0") at main.c:249
D:rrl:#3 0x00007fdc2ea31971 in isc_assertion_failed (file=file@entry=0x7fdc2ea7a958 "mem.c", line=line@entry=550, type=type@entry=isc_assertiontype_insist, cond=cond@entry=0x7fdc2ea7aa97 "malloced == 0") at assertions.c:47
D:rrl:#4 0x00007fdc2ea44583 in destroy (ctx=ctx@entry=0x55dca054da60) at jemalloc_shim.h:37
D:rrl:#5 0x00007fdc2ea448f4 in isc__mem_destroy (ctxp=0x55dc9ebade88 <named_g_mctx>, file=<optimized out>, line=<optimized out>) at mem.c:645
D:rrl:#6 0x000055dc9eb48d04 in main (argc=<optimized out>, argv=<optimized out>) at main.c:1556
D:rrl:--------------------------------------------------------------------------------
The memleak analysis points to:
add 0x7fdc0c039740 size 256 file netmgr/netmgr.c line 1480 mctx 0x55dca054da60
add 0x7fdc0c0c8a00 size 536 file netmgr/netmgr.c line 1647 mctx 0x55dca054da60
add 0x7fdc0c0395f0 size 256 file netmgr/netmgr.c line 1478 mctx 0x55dca054da60
add 0x7fdc0c6c9010 size 536 file netmgr/netmgr.c line 1644 mctx 0x55dca054da60
as it does happen only intermittently and in the softhsm2.4 branch (which is kind of broken - jemalloc+softhsm2.4 is no-no-no), it was only found later that this happens on "vanilla" build.
We changed the isc_mem_allocate()
and isc_mem_free()
on the ah_frees
and ah_handles
to isc_mem_put() and
isc_mem_put(), but missed the fact that
isc_mem_reallocate() is being used on L1642 and L1645.