Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl tool parallel transfer memory leaks #4772

Closed
geeknik opened this issue Dec 31, 2019 · 2 comments
Closed

curl tool parallel transfer memory leaks #4772

geeknik opened this issue Dec 31, 2019 · 2 comments

Comments

@geeknik
Copy link

@geeknik geeknik commented Dec 31, 2019

I did this

Compiled curl with clang + ASAN.

$ ./curl -q -K test0075.conf file:///dev/null
Warning: test0075.conf:1: warning:
Warning: '000000000000000000000000000000000000000000000000000000000000000000000
Warning: 0000000000000000000000000000000000000000000000000000000000000000000000
***SNIP***
Warning: test0075.conf:20: warning: ' is unknown
***SNIP***
curl: (3) bad range in URL position 12:
jhhhhhhhhh[hh2▒
           ^

=================================================================
==8894==ERROR: LeakSanitizer: detected memory leaks

Indirect leak of 32480 byte(s) in 3 object(s) allocated from:
    #0 0x49451d in malloc (/root/curl/build2-afl/src/curl+0x49451d)
    #1 0x99323a in Curl_hash_init /root/curl/build2-afl/lib/../../lib/hash.c:73:14

Indirect leak of 16385 byte(s) in 1 object(s) allocated from:
    #0 0x49451d in malloc (/root/curl/build2-afl/src/curl+0x49451d)
    #1 0x8e1d21 in Curl_open /root/curl/build2-afl/lib/../../lib/url.c:602:24

Indirect leak of 5912 byte(s) in 1 object(s) allocated from:
    #0 0x494692 in calloc (/root/curl/build2-afl/src/curl+0x494692)
    #1 0x8e1ad7 in Curl_open /root/curl/build2-afl/lib/../../lib/url.c:584:10
    #2 0x6b6595 in Curl_conncache_init /root/curl/build2-afl/lib/../../lib/conncache.c:120:27

Indirect leak of 408 byte(s) in 1 object(s) allocated from:
    #0 0x494692 in calloc (/root/curl/build2-afl/src/curl+0x494692)
    #1 0x5f5739 in Curl_multi_handle /root/curl/build2-afl/lib/../../lib/multi.c:349:30
    #2 0x521e57 in operate /root/curl/build2-afl/src/../../src/tool_operate.c:2486:18

Indirect leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0x49451d in malloc (/root/curl/build2-afl/src/curl+0x49451d)
    #1 0x8e1d95 in Curl_open /root/curl/build2-afl/lib/../../lib/url.c:608:30

Indirect leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x494692 in calloc (/root/curl/build2-afl/src/curl+0x494692)
    #1 0x6ad036 in Curl_resolver_init /root/curl/build2-afl/lib/../../lib/asyn-thread.c:116:15

SUMMARY: AddressSanitizer: 55457 byte(s) leaked in 8 allocation(s).

I expected the following

No memory leak.

curl/libcurl version

git commit 249f7b.

curl 7.68.0-DEV (x86_64-pc-linux-gnu) libcurl/7.68.0-DEV zlib/1.2.11
Release-Date: [unreleased]
Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp
Features: AsynchDNS IPv6 Largefile libz UnixSockets

operating system

Ubuntu

test0075.conf

MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw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P7/
7oZ3qAp1jcKV3nV1OqLpzelogxoKANivCv+Wd5UKdXI9ak9PT08KdXI9GtEu+BAQODTLEE7S8w66
CnWNSgwMDAwMFgwMJQCH3OyqcAyFDAwMDAwMDAwq+BJjMmpy/yMiKgqV+gr/hneVCnVyPSLpPyzp
IO0AIGSbm2xkZGRgZJubZGSVAfvtxtuVsK42unVyPWr1Eu7bLU1vTU1NTjo6Ojo6Ojo6Ojo6Ojo6
Ojo6Ojo6TU1hsrKy3iEh3t51dTqi6c3pd5UK3ZV/GjpcyCLr3xvrZGgn/yL10meA47Mq+BJjMmoK
/yMigYDQ/++6lHj/hneiCnVyPSIqCpX6dYpC3QrSTYDj8yr+/+6Jd2r6dXI93QotWqUA+fEyCoGA
0P/v2JUK/5Z3lQp1cj1qT09PTwp1cj0a0S74EBA4NMsQTtLzDroKdY1Kzw/tJGR3lQp1c4MaCgDz
7cbvGxsbG4Z3lQp1cj1qT09PTwotdY3Jl4C6Olxq/v+Gdxzu6dD/7wKVCv+Gd5UAAXI9ak9PT08K
LXVyNmh/GjpcNyLr3xvrZGgn/4Z3ogp1cj0Ougp1jUrPD+0iKgqV+nVyPcWKb29vbyMAaIAAsEFq
AIBPj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pd/9JYIDzEsbpIO2DZNLS0tLS0tLS/xMtwiDE0tLL0szS0tLS
0tLQ1dLS0tLSZGRkbGRk62RGZGRkTpUnlWqAQAsj7AAA+gHyKBIKh38=
@geeknik

This comment has been minimized.

Copy link
Author

@geeknik geeknik commented Dec 31, 2019

And $ echo "LUY9CnVyIDA=" | base64 -d > test0061.conf && ./curl -q -K test0061.conf file:///dev/null produces this leak in mime.c:

curl: (7) Failed to connect to 0 port 80: Connection refused

=================================================================
==2511==ERROR: LeakSanitizer: detected memory leaks

Indirect leak of 448 byte(s) in 1 object(s) allocated from:
    #0 0x49451d in malloc (/root/curl/build2-afl/src/curl+0x49451d)
    #1 0x6c51eb in curl_mime_addpart /root/curl/build2-afl/lib/../../lib/mime.c:1252:28

Indirect leak of 104 byte(s) in 1 object(s) allocated from:
    #0 0x49451d in malloc (/root/curl/build2-afl/src/curl+0x49451d)
    #1 0x6c4e6c in curl_mime_init /root/curl/build2-afl/lib/../../lib/mime.c:1215:24

Indirect leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x49451d in malloc (/root/curl/build2-afl/src/curl+0x49451d)
    #1 0x6c353b in curl_mime_data /root/curl/build2-afl/lib/../../lib/mime.c:1318:18

SUMMARY: AddressSanitizer: 553 byte(s) leaked in 3 allocation(s).
@jay jay added the memory-leak label Dec 31, 2019
@bagder

This comment has been minimized.

Copy link
Member

@bagder bagder commented Jan 4, 2020

I believe these are two separate issues. I've reproduced the first one.

bagder added a commit that referenced this issue Jan 4, 2020
... to fix memory leak in error path.

Fixes #4772
Reported-by: Brian Carpenter
@bagder bagder changed the title Memory leaks curl tool parallel transfer memory leaks Jan 4, 2020
@bagder bagder added the cmdline tool label Jan 4, 2020
@bagder bagder closed this in 271ec6b Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.