Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault occured in Aws::InitAPI when called by static object , previsously working for aws sdk version 1.8.186 #2961

Closed
xuandong93 opened this issue May 15, 2024 · 3 comments
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. p3 This is a minor priority issue

Comments

@xuandong93
Copy link

Describe the bug

Test constructor should successfully run but failed

Header

#ifndef testaws_HPP
#define testaws_HPP
#include <aws/core/Aws.h>

namespace Server
    {
        struct test
        {
            test();
        };

        static inline test t;

    } // namespace Server


//! Implementation
#include "server/impl/testaws.hpp"
#endif

IMPL

#ifndef testaws_HPP
#define testaws_HPP

#include "server/testaws.hpp"
inline Server::test::test()
    {
        Aws::SDKOptions options;
        Aws::InitAPI(options);
        Aws::ShutdownAPI(options);
        std::cout << " success\n";
    }
#endif

Main

#include "server/testaws.hpp"

int main ()
{
}

Expected Behavior

test constructor should successfully run but failed

Current Behavior

Segmentation fault at Aws::InitAPI()

Reproduction Steps

Possible Solution

Additional Information/Context

AWS CPP SDK version used

1.11.328

Compiler and Version used

gcc version 9.5.0

Operating System and version

ubuntu 22.04

@xuandong93 xuandong93 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 15, 2024
@sbiscigl
Copy link
Contributor

please consult the sdk usage dcumentation

The SDK for C++ and its dependencies use C++ static objects, and the order of static object destruction is not determined by the C++ standard. To avoid memory issues caused by the nondeterministic order of static variable destruction, do not wrap the calls to Aws::InitAPI and Aws::ShutdownAPI into another static object.

So yeah, you cant wrap the SDK in a static object because it causes a nondeterministic order of destruction.

@jmklix jmklix added closing-soon This issue will automatically close in 4 days unless further comments are made. p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels May 15, 2024
@xuandong93
Copy link
Author

got it and thanks !

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

3 participants