c:209 中发生致命错误情况:分配器 != ((void *)0) - aws-sdk-cpp

问题描述 投票:0回答:3

更新后遇到问题:使用 AWS 开发工具包将对象上传到 Amazon S3 存储桶:(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);
}

输出: /home/x/x/deps/aws-sdk-cpp/crt/aws-crt-cpp/crt/aws-c-common/source/allocator.c:209 中发生致命错误情况:分配器!= ((void *)0) 退出应用程序 没有可用的调用堆栈信息 已中止(核心已转储)

amazon-web-services aws-sdk aws-sdk-cpp
3个回答
2
投票

该错误出现在新版本的 aws 中。我降低版本并重新编译,它成功了


0
投票

我对这个问题不太了解,但我在稍微不同的上下文中遇到了相同的错误。就我而言,它出现在

__libc_start_main
(这是调用
main
的函数。)

我的问题是由

__libc_start_main
中清理的全局变量引起的,该变量是在
Aws::ShutdownAPI
调用之后发生的:

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

该问题仅在更新 AWS 库后才显现出来。我怀疑

Aws::S3::S3Client
不包含之前分配的任何内容,最近的版本改变了这一点。


0
投票

@l12 你能告诉我哪个版本适合你吗?

© www.soinside.com 2019 - 2024. All rights reserved.