aws-sdk-cpp: Segfault when destructing CloudwatchClient
Confirm by changing [ ] to [x] below to ensure that it’s a bug:
- I’ve gone though Developer Guide and API reference
- I’ve searched for previous similar issues and didn’t find any solution
Describe the bug I have been following the example set up and have code like:
Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
// options.cryptoOptions.initAndCleanupOpenSSL = false;
Aws::InitAPI(options);
Aws::Client::ClientConfiguration clientConfig;
Aws::CloudWatch::CloudWatchClient cw(clientConfig);
Aws::CloudWatch::Model::Dimension dimension;
dimension.SetName("UNIQUE_PAGES");
dimension.SetValue("URLS");
Aws::CloudWatch::Model::MetricDatum datum;
datum.SetMetricName("PAGES_VISITED");
datum.SetUnit(Aws::CloudWatch::Model::StandardUnit::None);
datum.SetValue(100);
datum.AddDimensions(dimension);
Aws::CloudWatch::Model::PutMetricDataRequest request;
request.SetNamespace("SITE/TRAFFIC");
request.AddMetricData(datum);
auto outcome = cw.PutMetricData(request);
if (!outcome.IsSuccess())
{
std::cout << "Failed to put sample metric data:" <<
outcome.GetError().GetMessage() << std::endl;
}
else
{
std::cout << "Successfully put sample metric data" << std::endl;
}
Aws::ShutdownAPI(options);
return false;
And this code segfaults after the Aws::ShutdownAPI call. In GDB I get an error like:
Thread 1 "cm" received signal SIGSEGV, Segmentation fault.
0x00007ffff75b0e0f in ?? () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
And using a few breakpoints I tracked down this issue:
Thread 1 "cm" hit Breakpoint 1, 0x00007ffff6e71f30 in Aws::Client::AWSClient::~AWSClient() () from /usr/local/lib/libaws-cpp-
sdk-monitoring.so
(gdb) c
Continuing.
Thread 1 "cm" hit Breakpoint 3, 0x00007ffff6b17bd0 in Aws::Internal::AWSHttpResourceClient::~AWSHttpResourceClient() ()
from /usr/local/lib/libaws-cpp-sdk-core.so
(gdb) c
Continuing.
Thread 1 "cm" hit Breakpoint 2, 0x00007ffff6b55fd0 in Aws::Http::CurlHttpClient::~CurlHttpClient() () from /usr/local/lib/libaws-
cpp-sdk-core.so
(gdb) c
Continuing.
Thread 1 "cm" hit Breakpoint 2, 0x00007ffff6b55fd0 in Aws::Http::CurlHttpClient::~CurlHttpClient() () from /usr/local/lib/libaws-
cpp-sdk-core.so
(gdb) c
Continuing.
Thread 1 "cm" received signal SIGSEGV, Segmentation fault.
0x00007ffff75b0e0f in ?? () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
So it seems like the CurlHttpClient destructor gets run twice for the same memory location and then it segfaults right afterwards. I’m not exactly sure how SSL plays into this as well but it seems like SSL can be problematic in multithreaded environments sometimes. The interesting thing is that the rest of the code works well and I can see the metrics reaching my Cloudwatch console.
SDK version number 1.9.29
Platform/OS/Hardware/Device What are you running the sdk on?
Windows 10 WSL/Ubuntu 18.04
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 15 (7 by maintainers)
Updating the sdk to latest master has now fixed this, thank you. Although this was very painful it does seem to work now.