1

I'm having an issue after updating: Upload an object to an Amazon S3 bucket using an AWS SDK:(https://docs.aws.amazon.com/AmazonS3/latest/userguide/example_s3_PutObject_section.html)

int main(int, char **)
{
    Aws::SDKOptions options;
    classB::initAwsApi(options);
    
        while (true)
    {

        
        //...
        
        if (threadApi.joinable())
        threadApi.join();
        
        threadApi = std::thread(request, &connection, &headers);
        std::this_thread::sleep_for(std::chrono::seconds(5));
        // if I close the stream, the error doesn't appear. But I would like to close the stream
        stream_.release();
    }
    
    if (threadApi.joinable())
            threadApi.join();

    // when closing the SDK, the error appears
    classB::shutdownAwsApi(options);
}

output: Fatal error condition occurred in /home/x/x/deps/aws-sdk-cpp/crt/aws-crt-cpp/crt/aws-c-common/source/allocator.c:209: allocator != ((void *)0) Exiting Application No call stack information available Aborted(core dumped)

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
l12
  • 61
  • 4

2 Answers2

0

the error was in the new version of aws. I lowered the version and compiled it again and it worked

l12
  • 61
  • 4
0

I don't know much about this issue but I got the same error in a slightly different context. In my case it appeared in __libc_start_main (this is the function that calls main.)

My problem was caused by a global variable that was cleaned up in __libc_start_main which occurred after the Aws::ShutdownAPI call:

inline Aws::S3::S3Client get_s3_client() {
    // HERE! This is a global variable that got destoryed after 'Aws::ShutdownAPI'.
    static std::optional<Aws::S3::S3Client> s3_client;

    if (s3_client.has_value()) {
        return s3_client.value();
    }

    QSettings settings;

    Aws::Auth::AWSCredentials credentials;
    credentials.SetAWSAccessKeyId(settings.value("AWS/AccessKeyId").value<QString>().toStdString());
    credentials.SetAWSSecretKey(settings.value("AWS/SecretKey").value<QString>().toStdString());

    Aws::Client::ClientConfiguration clientConfiguration;
    clientConfiguration.region = settings.value("AWS/Region").value<QString>().toStdString();

    s3_client.emplace(credentials, clientConfiguration);
    return s3_client.value();
}

The problem only became visible after updating the AWS library. I suspect that Aws::S3::S3Client did not contain anything that was allocated before and a recent release changed that.

asynts
  • 2,213
  • 2
  • 21
  • 35