Skip to content
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

memory leak on macOS M1 #12860

Closed
myudaZS opened this issue Feb 4, 2024 · 7 comments
Closed

memory leak on macOS M1 #12860

myudaZS opened this issue Feb 4, 2024 · 7 comments

Comments

@myudaZS
Copy link

myudaZS commented Feb 4, 2024

I did this

Hi,

I ran the following code which cause memory leaks after curl_easy_cleanup(hnd); was called. The memory leaks are identified using XCode instruments.

void CallCurl() {   
    CURL *hnd;
    hnd = curl_easy_init();
    curl_easy_setopt(hnd, CURLOPT_URL, "https://www.google.com");
    curl_easy_perform(hnd);
    curl_easy_cleanup(hnd);
}

I expected the following

I expected no memory leaks and instead i received the following leaks.

serialize_ECPublicKey
ECDSA_do_verify_new
ossl_ecdsa_verify
EVP_DigestVerifyFinal
tls13_server_certificate_verify_recv
tls13_handshake_perform
tls13_legacy_connect
ossl_connect_common
ssl_cf_connect
cf_setup_connect
cf_hc_connect
Curl_conn_connect
multi_runsingle
curl_multi_perform
curl_easy_perform
CallCurl()
main
start
ccMallocECCryptor
CCECCryptorImportKey
ECDSA_do_verify_new
ossl_ecdsa_verify
EVP_DigestVerifyFinal
tls13_server_certificate_verify_recv
tls13_handshake_perform
tls13_legacy_connect
ossl_connect_common
ssl_cf_connect
cf_setup_connect
cf_hc_connect
Curl_conn_connect
multi_runsingle
curl_multi_perform
curl_easy_perform
CallCurl()
main
start
ccMallocECCryptor
CCECCryptorImportKey
ECDSA_do_verify_new
ossl_ecdsa_verify
EVP_DigestVerifyFinal
tls13_server_certificate_verify_recv
tls13_handshake_perform
tls13_legacy_connect
ossl_connect_common
ssl_cf_connect
cf_setup_connect
cf_hc_connect
Curl_conn_connect
multi_runsingle
curl_multi_perform
curl_easy_perform
CallCurl()
main
start

curl/libcurl version

curl 8.1.2 (x86_64-apple-darwin23.0) libcurl/8.1.2 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.55.1
macOS shipped lib of curl.

operating system

sonoma 14.1.1 M1 amcOS.

@icing
Copy link
Contributor

icing commented Feb 5, 2024

These are all allocations inside the TLS library, in your case LibreSSL. Did your code run curl_global_cleanup(); at the end? Because that internally calls the LibreSSL cleanup functions that should free the allocations reported by you.

@myudaZS
Copy link
Author

myudaZS commented Feb 5, 2024

I tried calling curl_global_cleanup at the end, and i still get memory leaks:

    CURL *hnd;
    hnd = curl_easy_init();
    curl_easy_setopt(hnd, CURLOPT_URL, "https://www.google.com");
    curl_easy_perform(hnd);
    curl_easy_cleanup(hnd);
    curl_global_cleanup();

Memory leaks from instruments:

ccMallocECCryptor	
CCECCryptorImportKey	
ECDSA_do_verify_new	
ossl_ecdsa_verify	
EVP_DigestVerifyFinal	
tls13_server_certificate_verify_recv	
tls13_handshake_perform	
tls13_legacy_connect	
ossl_connect_common	
ssl_cf_connect	
cf_setup_connect	
cf_hc_connect	
Curl_conn_connect	
multi_runsingle	
curl_multi_perform	
curl_easy_perform	
main	
start

@jay
Copy link
Member

jay commented Feb 5, 2024

curl 8.1.2 (x86_64-apple-darwin23.0) libcurl/8.1.2 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.55.1

Please try the latest curl. There have been some changes to the way libcurl handles LibreSSL 2.7.0+ init/deinit in the last few versions.

/cc @vszakats

@jay jay added the memory-leak label Feb 5, 2024
@myudaZS
Copy link
Author

myudaZS commented Feb 5, 2024

On latest curl (8.6) the leak doesn't reproduce, however i want to use specifically the curl that is shipped with macOS.

@jay
Copy link
Member

jay commented Feb 5, 2024

We can't do anything about that. If an OS wants to maintain an older version then it's up to them to do that. You can use Apple's feedback assistant but aside from that I don't know what else.

@bagder
Copy link
Member

bagder commented Feb 5, 2024

If 8.6.0 doesn't leak, then the problem is already fixed and our job is done.

@bagder bagder closed this as completed Feb 5, 2024
@vszakats
Copy link
Member

vszakats commented Feb 5, 2024

Refs:
bec0c5b
#11611
9f2d229
#12525
#12526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants