Storage leaks
James Browning
jamesb192 at jamesb192.com
Mon Jan 13 00:37:46 UTC 2025
On Sunday, January 12, 2025 2:56:50 PM Pacific Standard Time Hal Murray wrote:
> James Browning said:
> > I would be more concerned in the near and intermediate terms about the
> > possibility of allocating memory to pointer that already have associated
> > memory.
>
> Right. But one way to find those is to fix the exit code to free
> everything so that anything left in use was a not-free-ed bug. Then
> valgrind can tell you about them and you can investigate. If the exit
> code doesn't free everything, you have to plow through all the legitimate
> leftovers. I think that will take too long to be practical.
>
> But we could iterate. Each time we find a legitmate leftover, fix the
> exit code to free it (and friends), then try again.
>
> The question is do we care enough about dangling blocks to fixup the
> free-on-exit code?
Probably, I think we need more developer hours per month to tackle it though.
```sh
$ sudo valgrind -s --leak-check=full -- ~/ntpsec/build/main/ntpd/ntpd -mnN
:::so much snipped:::
==260313== HEAP SUMMARY:
==260313== in use at exit: 906,447 bytes in 12,877 blocks
==260313== total heap usage: 50,137 allocs, 37,260 frees, 6,071,589 bytes
allocated
:::snip:::
==260313== LEAK SUMMARY:
==260313== definitely lost: 44 bytes in 6 blocks
==260313== indirectly lost: 816 bytes in 4 blocks
==260313== possibly lost: 57,900 bytes in 5 blocks
==260313== still reachable: 847,687 bytes in 12,862 blocks
==260313== suppressed: 0 bytes in 0 blocks
==260313== Reachable blocks (those to which a pointer was found) are not
shown.
==260313== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==260313==
==260313== ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)
```
It looks like the offending lines include:
5x create_string_token (ntp_scanner.c:769)
1x ssl_init (ssl_init.c:97)
1x hack_restrict (ntp_restrict.c:555)
1x alloc_auth_info (authkeys.c:285)
1x newpeer (ntp_peer.c:599)
1x init_recvbuff (ntp_recvbuff.c:91)
NOTE: This does not exercise the time server, refclocks (other than SHM), MS-
SNTP, NTS, stats logging, mode 6, and so forth.
Attached is the valgrind session minus the largely irrelevant ntpd messages.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: valgrind-cheap.log
Type: text/x-log
Size: 5508 bytes
Desc: not available
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20250112/0304bb97/attachment.bin>
More information about the devel
mailing list