Skip to content

Assertion triggered on AWSProfileConfigLoader without Aws::InitAPI #1451

Closed
@cosunae

Description

@cosunae

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
I was following the tutorial here, https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/examples-cloudwatch-publish-custom-metrics.html.
Without realizing it was not a complete example.
Without the line
Aws::InitAPI(options);
the constructor of CloudWatchClient seg faults in release mode. When I compiled aws-sdk-cpp in debug mode I obtained the stack trace I post below and finally realized that there was some initialization missing.

The assertion triggered is this one:

I would consider this as a bug, since I would expect the user gets (for a misconfiguration or ill-formed user program like this, since it does not follow the initialization as described in the docs) either a runtime exception or an error, not an assertion, or worse, in release a seg fault.
Btw, I am aware that aws-sdk-cpp does not use exceptions.

SDK version number
87a8456

Platform/OS/Hardware/Device
ubuntu 18.04, g++-8

To Reproduce (observed behavior)
int main() {
Aws::CloudWatch::CloudWatchClient cw;
}

Expected behavior
I would not expect an assertion, but rather a runtime exception or error code return (which is not possible in a constructor unless the pattern is moved into a maker function).

Logs/output
error stack trace, when compiling aws-sdk-cpp in debug mode
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff67e18b1 in __GI_abort () at abort.c:79
#2 0x00007ffff67d142a in __assert_fail_base (fmt=0x7ffff6958a38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x7ffff7616760 "s_configManager",
file=file@entry=0x7ffff7616710 "/software/aws-sdk-cpp/aws-cpp-sdk-core/source/config/AWSProfileConfigLoader.cpp", line=line@entry=512,
function=function@entry=0x7ffff7619780 <Aws::Config::GetCachedConfigValue(std::__cxx11::basic_string<char, std::char_traits, Aws::Allocator > const&)::PRETTY_FUNCTION> "Aws::String Aws::Config::GetCachedConfigValue(const String&)") at assert.c:92
#3 0x00007ffff67d14a2 in __GI___assert_fail (assertion=0x7ffff7616760 "s_configManager", file=0x7ffff7616710 "/software/aws-sdk-cpp/aws-cpp-sdk-core/source/config/AWSProfileConfigLoader.cpp", line=512,
function=0x7ffff7619780 <Aws::Config::GetCachedConfigValue(std::__cxx11::basic_string<char, std::char_traits, Aws::Allocator > const&)::PRETTY_FUNCTION> "Aws::String Aws::Config::GetCachedConfigValue(const String&)") at assert.c:101
#4 0x00007ffff75a7e46 in Aws::Config::GetCachedConfigValue (key="max_attempts") at /software/aws-sdk-cpp/aws-cpp-sdk-core/source/config/AWSProfileConfigLoader.cpp:512
#5 0x00007ffff75a3380 in Aws::Client::ClientConfiguration::ClientConfiguration (this=0x7fffffffce80) at /software/aws-sdk-cpp/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp:69

Metadata

Metadata

Assignees

Labels

guidanceQuestion that needs advice or information.response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 10 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions