-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Libcurl leaks with mbedtls. #12584
Comments
It smells like a potential mbedtls problem to me. The threaded resolver starts a new thread in which it only resolves a host name in, then it stops the thread again. There is never any TLS or other transfer business going on in that new thread. The new thread has nothing to do with mbedtls and the TLS layer never sees nor knows about that thread. The name resolving is done entirely independent and outside of the TLS layer. The question is probably if you then also disabled This looks like triggered by the mbedtls_ctr_drbg_seed call, but I see nothing special mentioned in their docs that would indicate we miss a cleanup or something. Can you? |
Yes , the program default enable USE_THREADS_WIN32. The program called mbedtls_ctr_drbg_free() at last but leaks also exists. |
I think it's the entropy thing that is not freed properly. Try this: diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c
index 4734ce026..159fa6c66 100644
--- a/lib/vtls/mbedtls.c
+++ b/lib/vtls/mbedtls.c
@@ -1204,10 +1204,13 @@ static int mbedtls_init(void)
return Curl_mbedtlsthreadlock_thread_setup();
}
static void mbedtls_cleanup(void)
{
+#ifdef THREADING_SUPPORT
+ mbedtls_entropy_free(&ts_entropy);
+#endif /* THREADING_SUPPORT */
(void)Curl_mbedtlsthreadlock_thread_cleanup();
}
static bool mbedtls_data_pending(struct Curl_cfilter *cf,
const struct Curl_easy *data) |
The entropy_free was never done for threaded builds, causing a small (fixed) memory leak. Reported-by: RevaliQaQ on github Fixes #12584
I change code and recompiled libcurl the leaks issue has been resolved. Thanks SO much. |
I did this
I build libcurl whith mbedtls3.5.1 and enable ENABLE_THREADED_RESOLVER. When I called curl_easy_setopt , I found a leak when the program end. The call stack is overflow:
I cleaned up the environment by using curl_easy_cleanup(curl), and, curl_global_cleanup();.
But leaks always exits.
When I disable ENABLE_THREADED_RESOLVER, leaks doesn't exit.
I expected the following
-Please tell me were I wrong?
-Please check out if the bug is exits.
curl/libcurl version
curl 8.5.0
mbedtls 3.5.1
operating system
Windows 11 with Visual Studio 2019 and CMAKE GUI 3.28.0
The text was updated successfully, but these errors were encountered: