Closed jeanbez closed 11 months ago
Hey @jeanbez thanks for reaching out i'd like to redirect you to our basic usage documentation specifically
Aws::InitAPI(options);
{
// make your SDK calls here.
}
Aws::ShutdownAPI(options);
because the specific issue is that your shared ptr for the s3 client still exists when you call shutdown. because of this shutdown will wait for you to delete the client to release the associated resources. refactoring your code to use the RAII to automatically clean up the client like
#include <iostream>
#include <aws/core/Aws.h>
#include <aws/s3-crt/S3CrtClient.h>
#include <aws/s3-crt/model/CreateBucketRequest.h>
int main() {
Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
Aws::InitAPI(options);
{
std::shared_ptr<Aws::S3Crt::S3CrtClient> aws_crt_client;
const double throughput_target_gbps = 100;
const uint64_t part_size = 1 * 1024 * 1024; // 1 MB
Aws::S3Crt::ClientConfiguration ctr_config;
ctr_config.region = Aws::Region::US_WEST_1;
ctr_config.throughputTargetGbps = throughput_target_gbps;
ctr_config.partSize = part_size;
aws_crt_client = std::make_shared<Aws::S3Crt::S3CrtClient>(ctr_config);
Aws::S3Crt::Model::ListBucketsOutcome outcome = aws_crt_client->ListBuckets();
if (outcome.IsSuccess()) {
std::cout << "All buckets under my account:" << std::endl;
for (auto const&bucket: outcome.GetResult().GetBuckets()) {
std::cout << " * " << bucket.GetName() << std::endl;
}
std::cout << std::endl;
}
else {
std::cout << "ListBuckets error:\n" << outcome.GetError() << std::endl << std::endl;
}
}
Aws::ShutdownAPI(options);
return 0;
}
will make sure that std::shared_ptr<Aws::S3Crt::S3CrtClient> aws_crt_client
has been destructed when shutdown is called. this could also be accomplished by adding aws_crt_client.reset();
before calling shutdown but i'd recommend using RAII instead of directly invoking reset.
let me know if you have any questions.
got it, thanks! calling reset solved the issue
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
When calling the
Aws::ShutdownAPI(options)
the execution seems to hang, this happens in MacOS with the latest version of the SDK and only when using the S3Crt.Expected Behavior
Shutdown to complete and application to exit successfully.
Current Behavior
The logs indicate it get stuck mid-shutdown process:
Reproduction Steps
Sample code based on the provided examples in documentation that cause this behavior:
The contents are listed, and upon calling shutdown, the code hangs indefinitely. Upon interrupting the execution in lldb the stack trace is the following:
Possible Solution
No response
Additional Information/Context
No response
AWS CPP SDK version used
1.11.211
Compiler and Version used
Apple clang version 15.0.0 (clang-1500.0.40.1)
Operating System and version
MacOs Sonoma 14.0 (23A344)