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: James Read via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 26 May 2020 12:47:00 +0100

On Tue, May 26, 2020 at 7:30 AM Patrick Monnerat via curl-library <
curl-library_at_cool.haxx.se> wrote:

> 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.
>

Does the example at https://curl.haxx.se/libcurl/c/ephiperfifo.html have
the same problem? The code I'm trying to debug seems to follow that pattern
very closely. Do you have any example code that fixes the problem?

James Read

>
> Patrick
>
> -------------------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

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