Skip to content

Aws::ShutdownAPI hangs when S3Crt is used #2769

Description

@jeanbez

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:

[INFO] 2023-11-28 23:13:05.921 Aws_Init_Cleanup [0x7ff8517cae80] Shutdown AWS SDK for C++.
[DEBUG] 2023-11-28 23:13:05.922 HttpClientFactory [0x7ff8517cae80] Cleanup Http Static State
[DEBUG] 2023-11-28 23:13:05.922 HttpClientFactory [0x7ff8517cae80] Cleanup Curl Http Client

Reproduction Steps

Sample code based on the provided examples in documentation that cause this behavior:

#include <iostream>
#include <aws/core/Aws.h>
#include <aws/s3-crt/S3CrtClient.h>
#include <aws/s3-crt/model/CreateBucketRequest.h>
#include <aws/s3-crt/model/BucketLocationConstraint.h>
#include <aws/s3-crt/model/DeleteBucketRequest.h>
#include <aws/s3-crt/model/PutObjectRequest.h>
#include <aws/s3-crt/model/GetObjectRequest.h>
#include <aws/s3-crt/model/DeleteObjectRequest.h>
#include <aws/s3-crt/model/HeadObjectRequest.h>

int main() {
    std::shared_ptr<Aws::S3Crt::S3CrtClient> aws_crt_client;

    Aws::SDKOptions options;
    options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;

    Aws::InitAPI(options);

    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;
}

The contents are listed, and upon calling shutdown, the code hangs indefinitely. Upon interrupting the execution in lldb the stack trace is the following:

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007ff80e1b55d6 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007ff80e1f276b libsystem_pthread.dylib`_pthread_cond_wait + 1211
    frame #2: 0x00007ff80e12a3c2 libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
    frame #3: 0x00007ff80e12ac37 libc++.1.dylib`std::__1::__assoc_sub_state::__sub_wait(std::__1::unique_lock<std::__1::mutex>&) + 45
    frame #4: 0x00007ff80e12ac9e libc++.1.dylib`std::__1::__assoc_sub_state::wait() + 46
    frame #5: 0x0000000101216d85 libaws-crt-cpp.dylib`Aws::Crt::Io::ClientBootstrap::~ClientBootstrap() + 45
    frame #6: 0x0000000100845b70 libaws-cpp-sdk-core.dylib`std::__1::shared_ptr<Aws::Crt::Io::ClientBootstrap>::operator=[abi:v160006](std::__1::shared_ptr<Aws::Crt::Io::ClientBootstrap> const&) + 66
    frame #7: 0x0000000100845c5d libaws-cpp-sdk-core.dylib`Aws::CleanupCrt() + 34
    frame #8: 0x0000000100845787 libaws-cpp-sdk-core.dylib`Aws::ShutdownAPI(Aws::SDKOptions const&) + 544

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 10 days.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions