curl / Mailing Lists / curl-users / 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" when using gnutls as SSL library

From: Daniel Stenberg via curl-users <>
Date: Thu, 21 Nov 2019 00:08:35 +0100 (CET)

On Wed, 20 Nov 2019, David Guillen Fandos via curl-users wrote:

Thanks for your report and research into this issue! (Since this is rather
deep debugging and error tracking, it might be more suitable to either discuss
on the curl-library list or perhaps file as an issue.)

> Using nonblocking (this is the multi interface? I think the non-multi are
> also using nonblocking) API results in the SSL backend being also used in a
> non-blocking way.

Everything internally is "multi" and everything is using non-blocking sockets,
so for the gnutls code there's only one way of working no matter which libcurl
API that's used.

> The nonblocking code seems to go through the gtls_connect_step1 path which
> seems to me like it could be initializing "cred" (BACKEND->cred) more than
> once, which under the hood is a calloc/malloc memory allocation. On the
> other hand openssl seems to be checking for a non-NULL pointer in the CTX
> and freeing when appropriate.

Can't you just add some printf() code in there to see if it truly gets called
multiple times when you see the problem? BTW, does this preproduces easily for
you? Like every time on all https sites you test or is it less likely to
trigger than so?

Can you tell us how to reproduce this problem? Do you perhaps have a suggested

Which gnutls version is this?

> the cred pointer, missing some memory along the way. However I fail to
> understand how come valgrind and other tools are happy with this.

Yes, that's really curious. I would say that it would make it not actually a
memory leak, but could still very well be a too much memory consumed error.

  / | Get the best commercial curl support there is - from me
                   | Private help, bug fixes, support, ports, new features
Received on 2019-11-21