cURL / Mailing Lists / curl-library / Single Mail

curl-library

Memoryleak when binding to interface?

From: Ståle Kristoffersen <staalebk_at_ifi.uio.no>
Date: Tue, 18 Sep 2012 13:15:37 +0200

Hi,
I'm seeing a memory leak when using libcurl, and I have reduced my testcase
to the following:
http://pastebin.com/0MxcrKsQ

When I run this in valgrind I get the following output:

$ valgrind --tool=memcheck --leak-check=full ./leak http://10.0.30.11/test.bin
==12235== Memcheck, a memory error detector
==12235== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==12235== Using Valgrind-3.6.1-Debian and LibVEX; rerun with -h for
copyright info
==12235== Command: ./leak http://10.0.30.11/test.bin
==12235==
Round 1
Round 2
Round 3
Round 4
Round 5
Round 6
Round 7
Round 8
Round 9
Round 10
==12235==
==12235== HEAP SUMMARY:
==12235== in use at exit: 27 bytes in 9 blocks
==12235== total heap usage: 282 allocs, 273 frees, 100,718 bytes
allocated
==12235==
==12235== 27 bytes in 9 blocks are definitely lost in loss record 1 of 1
==12235== at 0x4C28F9F: malloc (vg_replace_malloc.c:236)
==12235== by 0x50F9441: strdup (strdup.c:43)
==12235== by 0x4E44A8B: create_conn (in /usr/local/lib/libcurl.so.4.2.0)
==12235== by 0x4E4AC38: Curl_connect (in
/usr/local/lib/libcurl.so.4.2.0)
==12235== by 0x4E52100: Curl_do_perform (in
/usr/local/lib/libcurl.so.4.2.0)
==12235== by 0x400862: main (leak.c:30)
==12235==
==12235== LEAK SUMMARY:
==12235== definitely lost: 27 bytes in 9 blocks
==12235== indirectly lost: 0 bytes in 0 blocks
==12235== possibly lost: 0 bytes in 0 blocks
==12235== still reachable: 0 bytes in 0 blocks
==12235== suppressed: 0 bytes in 0 blocks
==12235==
==12235== For counts of detected and suppressed errors, rerun with: -v
==12235== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)

If I do not bind to the interface (just by commenting out the line setting
CURLOPT_INTERFACE) I see no leaks in valgrind.

Am I using libcurl incorrectly or is it a bug?

-- 
Ståle Kristoffersen
staalebk_at_ifi.uio.no
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-18