-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
bugThis issue is a bug.This issue is a bug.p2This is a standard priority issueThis is a standard priority issue
Description
- 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
SDK Shutdown segfaults and has valgrind memory issues, apparently around CleanupHttp / CleanupCrypto. This issue only seems to happen if a static pointer to a class which inits and cleans up the SDK is used. Curious why this would be the case.
SDK version number
1.8.113
Platform/OS/Hardware/Device
Fedora 33, (GCC) 10.2.1 20201125
To Reproduce (observed behavior)
#include <memory>
#include <aws/core/Aws.h>
class AwsLifetime {
public:
AwsLifetime() {
Aws::InitAPI(options);
}
~AwsLifetime() {
Aws::ShutdownAPI(options);
}
private:
Aws::SDKOptions options;
};
static std::unique_ptr<AwsLifetime> aws;
int main() {
aws = std::make_unique<AwsLifetime>();
return 0;
}
$ g++ -std=c++17 -Wall -Werror -O2 -laws-cpp-sdk-core -o test test.cpp
$ valgrind --tool=memcheck --leak-check=full ./test
Expected behavior
Runs, clean valgrind output. With SDK version 1.7.323, (GCC) 10.1.1 20200507 Fedora 32
==3600== Memcheck, a memory error detector
==3600== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3600== Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info
==3600== Command: ./test
==3600==
==3600==
==3600== HEAP SUMMARY:
==3600== in use at exit: 0 bytes in 0 blocks
==3600== total heap usage: 4,050 allocs, 4,050 frees, 237,867 bytes allocated
==3600==
==3600== All heap blocks were freed -- no leaks are possible
==3600==
==3600== For lists of detected and suppressed errors, rerun with: -s
==3600== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Logs/output
On Fedora 33 with versions described above
First invalid read:
==591656== Memcheck, a memory error detector
==591656== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==591656== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==591656== Command: ./test
==591656==
==591656== Invalid read of size 8
==591656== at 0x48C8809: Aws::Http::CleanupHttp() (in /usr/lib64/libaws-cpp-sdk-core.so)
==591656== by 0x490A27C: Aws::ShutdownAPI(Aws::SDKOptions const&) (in /usr/lib64/libaws-cpp-sdk-core.so)
==591656== by 0x4014A7: std::unique_ptr<AwsLifetime, std::default_delete<AwsLifetime> >::~unique_ptr() (in /home/fedora/test)
==591656== by 0x4CF6236: __run_exit_handlers (in /usr/lib64/libc-2.32.so)
==591656== by 0x4CF63DF: exit (in /usr/lib64/libc-2.32.so)
==591656== by 0x4CDE1E8: (below main) (in /usr/lib64/libc-2.32.so)
==591656== Address 0x5a87020 is 16 bytes inside a block of size 24 free'd
==591656== at 0x483A9F5: free (vg_replace_malloc.c:538)
==591656== by 0x4CF6236: __run_exit_handlers (in /usr/lib64/libc-2.32.so)
==591656== by 0x4CF63DF: exit (in /usr/lib64/libc-2.32.so)
==591656== by 0x4CDE1E8: (below main) (in /usr/lib64/libc-2.32.so)
==591656== Block was alloc'd at
==591656== at 0x4839809: malloc (vg_replace_malloc.c:307)
==591656== by 0x48C8730: Aws::Http::InitHttp() (in /usr/lib64/libaws-cpp-sdk-core.so)
==591656== by 0x49304F3: Aws::InitAPI(Aws::SDKOptions const&) (in /usr/lib64/libaws-cpp-sdk-core.so)
==591656== by 0x4011A7: main (in /home/fedora/test)
==591656==
Additional context
With Logging on simply running the program
[~]$ ./test
[DEBUG] 2020-12-30 16:01:19.044 FileSystemUtils [139993724766464] Environment value for variable HOME is /home/fedora
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Home directory is missing the final / appending one to normalize
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Final Home Directory is /home/fedora/
[INFO] 2020-12-30 16:01:19.045 Aws::Config::AWSConfigFileProfileConfigLoader [139993724766464] Initializing config loader against fileName /home/fedora/.aws/credentials and using profilePrefix = 0
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Environment value for variable HOME is /home/fedora
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Home directory is missing the final / appending one to normalize
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Final Home Directory is /home/fedora/
[INFO] 2020-12-30 16:01:19.045 Aws::Config::AWSConfigFileProfileConfigLoader [139993724766464] Initializing config loader against fileName /home/fedora/.aws/config and using profilePrefix = 1
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Environment value for variable HOME is /home/fedora
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Home directory is missing the final / appending one to normalize
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Final Home Directory is /home/fedora/
[INFO] 2020-12-30 16:01:19.045 Aws::Config::AWSConfigFileProfileConfigLoader [139993724766464] Unable to open config file /home/fedora/.aws/credentials for reading.
[INFO] 2020-12-30 16:01:19.045 Aws::Config::AWSProfileConfigLoader [139993724766464] Failed to reload configuration.
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Environment value for variable HOME is /home/fedora
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Home directory is missing the final / appending one to normalize
[DEBUG] 2020-12-30 16:01:19.045 FileSystemUtils [139993724766464] Final Home Directory is /home/fedora/
[INFO] 2020-12-30 16:01:19.045 Aws::Config::AWSConfigFileProfileConfigLoader [139993724766464] Unable to open config file /home/fedora/.aws/config for reading.
[INFO] 2020-12-30 16:01:19.045 Aws::Config::AWSProfileConfigLoader [139993724766464] Failed to reload configuration.
[INFO] 2020-12-30 16:01:19.046 CurlHttpClient [139993724766464] Initializing Curl library with version: 7.71.1, ssl version: OpenSSL/1.1.1i-fips
[DEBUG] 2020-12-30 16:01:19.046 ClientConfiguration [139993724766464] ClientConfiguration will use SDK Auto Resolved profile: [default] if not specified by users.
[WARN] 2020-12-30 16:01:19.046 ClientConfiguration [139993724766464] Retry Strategy will use the default max attempts.
[INFO] 2020-12-30 16:01:19.046 EC2MetadataClient [139993724766464] Creating AWSHttpResourceClient with max connections 2 and scheme http
[INFO] 2020-12-30 16:01:19.046 CurlHandleContainer [139993724766464] Initializing CurlHandleContainer with size 2
[INFO] 2020-12-30 16:01:19.046 CurlHandleContainer [139993724766464] Cleaning up CurlHandleContainer.
Segmentation fault (core dumped)
Any insights would be appreciated
kshcherbatov, xonatius, seanabraham and raphasampaio
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.p2This is a standard priority issueThis is a standard priority issue