Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#27670 closed defect (fixed)

Memleak on tor master 95fcad4088eba52e

Reported by: dgoulet Owned by:
Priority: Medium Milestone: Tor: 0.3.5.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords: regression, memleak, 035-must
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

On latest master, normal client starts with a Ctrl+C. Notice the "Listener on ???:0" which seems to me the end of a list we fail to recognize? And then the memleak.

Sep 12 15:21:48.615 [notice] Tor 0.3.5.0-alpha-dev (git-95fcad4088eba52e) running on Linux with Libevent 2.1.8-stable, OpenSSL 1.1.0h, Zlib 1.2.11, Liblzma 5.2.2, and Libzstd N/A.
Sep 12 15:21:48.615 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Sep 12 15:21:48.615 [notice] This version is not a stable Tor release. Expect more bugs than usual.
Sep 12 15:21:48.615 [notice] Read configuration file "/home/dgoulet/temp/tor/torrc".
Sep 12 15:21:48.618 [warn] ControlPort is open, but no authentication method has been configured.  This means that any program on your computer can reconfigure your Tor.  That's bad!  You should upgrade your Tor controller as soon as possible.
Sep 12 15:21:48.619 [notice] Opening Socks listener on 127.0.0.1:9250
Sep 12 15:21:48.620 [notice] Opened Socks listener on 127.0.0.1:9250
Sep 12 15:21:48.620 [notice] Opening Socks listener on /home/dgoulet/temp/tor/client/socks.sock
Sep 12 15:21:48.620 [notice] Opened Socks listener on ???:0
Sep 12 15:21:48.620 [notice] Opening Control listener on 127.0.0.1:9051
Sep 12 15:21:48.620 [notice] Opened Control listener on 127.0.0.1:9051
Sep 12 15:21:48.620 [notice] Opening Control listener on /home/dgoulet/temp/tor/client/control.sock
Sep 12 15:21:48.620 [notice] Opened Control listener on ???:0
^C
=================================================================
==22622==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x7fd64617ef30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x555bb37c2caa in tor_malloc_ src/lib/malloc/malloc.c:45
    #2 0x555bb37be8e5 in smartlist_new src/lib/smartlist_core/smartlist_core.c:28
    #3 0x555bb3689c2d in retry_all_listeners src/core/mainloop/connection.c:2831
    #4 0x555bb312bcbd in retry_listeners_callback src/core/mainloop/main.c:2342
    #5 0x555bb31427fe in periodic_event_dispatch src/core/mainloop/periodic.c:56
    #6 0x7fd645ab4a10  (/usr/lib/x86_64-linux-gnu/libevent-2.1.so.6+0x1ea10)

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x7fd64617ef30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x555bb37c2caa in tor_malloc_ src/lib/malloc/malloc.c:45
    #2 0x555bb37be8e5 in smartlist_new src/lib/smartlist_core/smartlist_core.c:28
    #3 0x555bb3689c2d in retry_all_listeners src/core/mainloop/connection.c:2831
    #4 0x555bb363108b in options_act_reversible src/app/config/config.c:1493
    #5 0x555bb363108b in set_options src/app/config/config.c:903
    #6 0x555bb363b827 in options_init_from_string src/app/config/config.c:5466
    #7 0x555bb363ce10 in options_init_from_torrc src/app/config/config.c:5230
    #8 0x555bb31401d8 in tor_init src/core/mainloop/main.c:3540
    #9 0x555bb3141b00 in tor_run_main src/core/mainloop/main.c:4275
    #10 0x555bb312b9ab in tor_main src/feature/api/tor_api.c:164
    #11 0x555bb31268bb in main src/app/main/tor_main.c:32
    #12 0x7fd64443309a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)

Indirect leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7fd64617ef30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x555bb37c2caa in tor_malloc_ src/lib/malloc/malloc.c:45
    #2 0x555bb37c2d41 in tor_malloc_zero_ src/lib/malloc/malloc.c:71
    #3 0x555bb37be999 in smartlist_new src/lib/smartlist_core/smartlist_core.c:31
    #4 0x555bb3689c2d in retry_all_listeners src/core/mainloop/connection.c:2831
    #5 0x555bb312bcbd in retry_listeners_callback src/core/mainloop/main.c:2342
    #6 0x555bb31427fe in periodic_event_dispatch src/core/mainloop/periodic.c:56
    #7 0x7fd645ab4a10  (/usr/lib/x86_64-linux-gnu/libevent-2.1.so.6+0x1ea10)

Indirect leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7fd64617ef30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x555bb37c2caa in tor_malloc_ src/lib/malloc/malloc.c:45
    #2 0x555bb37c2d41 in tor_malloc_zero_ src/lib/malloc/malloc.c:71
    #3 0x555bb37be999 in smartlist_new src/lib/smartlist_core/smartlist_core.c:31
    #4 0x555bb3689c2d in retry_all_listeners src/core/mainloop/connection.c:2831
    #5 0x555bb363108b in options_act_reversible src/app/config/config.c:1493
    #6 0x555bb363108b in set_options src/app/config/config.c:903
    #7 0x555bb363b827 in options_init_from_string src/app/config/config.c:5466
    #8 0x555bb363ce10 in options_init_from_torrc src/app/config/config.c:5230
    #9 0x555bb31401d8 in tor_init src/core/mainloop/main.c:3540
    #10 0x555bb3141b00 in tor_run_main src/core/mainloop/main.c:4275
    #11 0x555bb312b9ab in tor_main src/feature/api/tor_api.c:164
    #12 0x555bb31268bb in main src/app/main/tor_main.c:32
    #13 0x7fd64443309a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)

SUMMARY: AddressSanitizer: 288 byte(s) leaked in 4 allocation(s).

Child Tickets

Change History (6)

comment:1 Changed 8 months ago by nickm

Ooh. This is probably the result of the new #17873 code.

comment:2 Changed 8 months ago by dgoulet

So the leak is one thing, easy to fix.

The weird log is from commit: 27c868eff19dbcc208f6db66ec3e2de2104fa754. We need to not use fmt_addrport() if it is a Unix path. Or ditch that commit.

comment:3 Changed 8 months ago by nickm

My branch ticket27670 should fix the fmt_addrport() thing. Please feel free to add the memory leak fixes?

comment:4 Changed 8 months ago by dgoulet

Status: newneeds_review

Memleak fix in ticket27670_035_01 (which includes your fix nickm).

comment:5 Changed 8 months ago by nickm

Resolution: fixed
Status: needs_reviewclosed

lgtm; testing and merging.

comment:6 Changed 8 months ago by teor

I think coverity found this leak (or a similar leak) as CID 1439317:

/src/core/mainloop/connection.c: 2910 in retry_all_listeners()

Note: See TracTickets for help on using tickets.