Opened 3 years ago

Closed 3 years ago

#21788 closed defect (fixed)

Very small memory leak with --verify-config

Reported by: Jigsaw52 Owned by: Jigsaw52
Priority: Very Low Milestone: Tor: 0.3.1.x-final
Component: Core Tor/Tor Version: Tor: unspecified
Severity: Trivial Keywords: memory leak
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


When tor is run with the flag --verify-config, there is a memory leak of 45 bytes. Although the leak is insignificant, not leaking any memory helps testing the configuration related code against memory leaks.

This leak is due to clean_up_backtrace_handler not being called during tor shutdown process. I believe the fix is calling it inside tor_free_all. I will post a link to a branch with my proposed fix.

Valgrind log:

user@lubuntu:~/Desktop/tor$ valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all  /usr/local/bin/tor --verify-config
==19135== Memcheck, a memory error detector
==19135== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==19135== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==19135== Command: /usr/local/bin/tor --verify-config
Mar 20 00:59:33.916 [notice] Tor (git-411736a13250586c) running on Linux with Libevent 2.0.21-stable, OpenSSL 1.0.2g and Zlib 1.2.8.
Mar 20 00:59:34.005 [notice] Tor can't help you if you use it wrong! Learn how to be safe at
Mar 20 00:59:34.008 [notice] This version is not a stable Tor release. Expect more bugs than usual.
Mar 20 00:59:34.036 [notice] Read configuration file "/usr/local/etc/tor/torrc".
Configuration was valid
==19135== HEAP SUMMARY:
==19135==     in use at exit: 45 bytes in 1 blocks
==19135==   total heap usage: 8,709 allocs, 8,708 frees, 460,735 bytes allocated
==19135== 45 bytes in 1 blocks are still reachable in loss record 1 of 1
==19135==    at 0x4C2CB3F: malloc (in /usr/lib/valgrind/
==19135==    by 0x61CBB4F: __vasprintf_chk (vasprintf_chk.c:80)
==19135==    by 0x2669F3: vasprintf (stdio2.h:210)
==19135==    by 0x2669F3: tor_vasprintf (compat.c:539)
==19135==    by 0x2669F3: tor_asprintf (compat.c:516)
==19135==    by 0x2657E1: configure_backtrace_handler (backtrace.c:232)
==19135==    by 0x1556AF: tor_main (main.c:3609)
==19135==    by 0x14F238: main (tor_main.c:34)
==19135== LEAK SUMMARY:
==19135==    definitely lost: 0 bytes in 0 blocks
==19135==    indirectly lost: 0 bytes in 0 blocks
==19135==      possibly lost: 0 bytes in 0 blocks
==19135==    still reachable: 45 bytes in 1 blocks
==19135==         suppressed: 0 bytes in 0 blocks
==19135== For counts of detected and suppressed errors, rerun with: -v
==19135== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Child Tickets

Change History (3)

comment:1 Changed 3 years ago by Jigsaw52

Status: newneeds_revision

comment:2 Changed 3 years ago by nickm

Milestone: Tor: 0.3.1.x-final
Status: needs_revisionneeds_review

comment:3 Changed 3 years ago by nickm_mobile

Resolution: fixed
Status: needs_reviewclosed

Merged, changes file added.

Note: See TracTickets for help on using tickets.