Description
Describe the bug
source file: aws-sdk-cpp-1.10.20/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp
Sorry my English is not very good, I hope you can understand what I mean.
For every Aws::InitAPI and Aws::ShutdownAPI pair, aws sdk calls CurlHttpClient::InitGlobalState() and CurlHttpClient::CleanupGlobalState(). In the InitGlobalState function there is a bool type flag variable isInit, because of it InitGlobalState only calls libcurl initialization API curl_global_init once, but in CleanupGlobalState function, this flag won't be unset, so CleanupGlobalState is calling libcurl cleanup API curl_global_cleanup without any restriction, according to libcurl, This function releases resources acquired by curl_global_init and application should call curl_global_cleanup once for each call you make to curl_global_init.
For my case I use both aws S3 and libcurl based https, and aws sdk code cleanup the global initialization for my libcurl based code and caused CURLE_OUT_OF_MEMORY error when I try to make a https POST.
Expected Behavior
AWS sdk shall should call [curl_global_cleanup] once for each call it makes to [curl_global_init]
Current Behavior
AWS sdk calls [curl_global_cleanup] only once but calls [curl_global_init] multi-times
Reproduction Steps
always
Possible Solution
void CurlHttpClient::CleanupGlobalState()
{
if(true==isInit)
{
curl_global_cleanup();
isInit=false;
}
}
Additional Information/Context
https://curl.se/libcurl/c/curl_global_cleanup.html
AWS CPP SDK version used
aws-sdk-cpp-1.10.20
Compiler and Version used
aarch64-linux-gnu gcc version 9.4.0
Operating System and version
aarch64-linux-gnu
Activity
SergeyRyabinin commentedon Jun 14, 2023
Hi @ButcherOfBlaviken ,
SDK options struct has an option to disable calling this curl method, if you prefer to call it yourself:
aws-sdk-cpp/src/aws-cpp-sdk-core/include/aws/core/Aws.h
Lines 90 to 94 in 0175cb2
At the same time, you are right with a proposed suggestion that we should check the flag value before attempting to
curl_global_cleanup
.If you prefer, you could submit a PR with a change, otherwise we will follow up on it later.
Best regards,
Sergey
jmklix commentedon Mar 13, 2024
Testing your suggested changes
github-actions commentedon Mar 14, 2024
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.