skip to Main Content

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)

2

Answers


  1. Chosen as BEST ANSWER

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


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search