curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Memory leak with curl_multi_socket_action

From: Patrick Monnerat via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 26 May 2020 08:21:32 +0200

On 5/26/20 1:15 AM, James Read via curl-library wrote:
>
> git clone https://github.com/JamesRead5737/libcurlmemoryleak.git
>
> No need to make. Just compile with gcc crawler.c -g -lssl -lcurl
> Run valgrind with valgrind -v --tool=memcheck --leak-check=full
> --show-reachable=yes --track-origins=yes --log-file=memcheck.log ./a.out
>
> This should reproduce what I've been talking about.
>
Upon termination, you call curl_multi_cleanup() that still has easy
handles attached to. As a consequence, they are never freed. See 1st
description paragraph of
https://curl.haxx.se/libcurl/c/curl_multi_cleanup.html.

Unfortunately, there is no API that lists attached easy handles, so you
have to keep a list externally and unlink+cleanup them explicitly before
curl_multi_cleanup call. I tried that (with a very primitive
single-linked list in ConnInfo) and it works: all memory leaks disappear.

Patrick

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-05-26