Skip to content

sdk code is repeatedly calling curl_global_cleanup #2538

Closed
@ButcherOfBlaviken

Description

@ButcherOfBlaviken

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p3This is a minor priority issuepending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions