Segmentation fault occured in Aws::InitAPI when called by static object , previsously working for aws sdk version 1.8.186
xuandong93 opened this issue · 3 comments
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
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.
got it and thanks !
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.