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

DynamoDBClient is there a memory leak? #1953

Closed
nqf opened this issue Jun 10, 2022 · 5 comments
Closed

DynamoDBClient is there a memory leak? #1953

nqf opened this issue Jun 10, 2022 · 5 comments
Assignees
Labels
bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue.

Comments

@nqf
Copy link

nqf commented Jun 10, 2022

Describe the bug

==12586== Memcheck, a memory error detector
==12586== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12586== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==12586== Command: ./cpp-graphql-server --type=2
==12586== Parent PID: 24798
==12586== 
==12586== 
==12586== HEAP SUMMARY:
==12586==     in use at exit: 8,232 bytes in 159 blocks
==12586==   total heap usage: 40,292 allocs, 40,133 frees, 3,774,762 bytes allocated
==12586== 
==12586== 864 (336 direct, 528 indirect) bytes in 2 blocks are definitely lost in loss record 137 of 139
==12586==    at 0x4C2B067: malloc (vg_replace_malloc.c:380)
==12586==    by 0xB8227D: CRYPTO_malloc (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xB822B0: CRYPTO_zalloc (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xB7057D: EVP_CIPHER_CTX_new (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xD963B2: s2n_drbg_instantiate (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xD910D4: s2n_get_private_random_data (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xD9112C: s2n_openssl_compat_rand (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xBA9172: RAND_bytes (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0x6917BA: Aws::Utils::Crypto::SecureRandomBytes_OpenSSLImpl::GetBytes(unsigned char*, unsigned long) (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0x67D610: Aws::Utils::UUID::RandomUUID() (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0x6AE7B7: Aws::Client::AWSClient::AttemptExhaustively(Aws::Http::URI const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0x6B071B: Aws::Client::AWSJsonClient::MakeRequest(Aws::Http::URI const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586== 
==12586== 864 (336 direct, 528 indirect) bytes in 2 blocks are definitely lost in loss record 138 of 139
==12586==    at 0x4C2B067: malloc (vg_replace_malloc.c:380)
==12586==    by 0xB8227D: CRYPTO_malloc (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xB822B0: CRYPTO_zalloc (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xB7057D: EVP_CIPHER_CTX_new (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xD963B2: s2n_drbg_instantiate (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xD910EE: s2n_get_private_random_data (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xD9112C: s2n_openssl_compat_rand (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0xBA9172: RAND_bytes (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0x6917BA: Aws::Utils::Crypto::SecureRandomBytes_OpenSSLImpl::GetBytes(unsigned char*, unsigned long) (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0x67D610: Aws::Utils::UUID::RandomUUID() (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0x6AE7B7: Aws::Client::AWSClient::AttemptExhaustively(Aws::Http::URI const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586==    by 0x6B071B: Aws::Client::AWSJsonClient::MakeRequest(Aws::Http::URI const&, Aws::AmazonWebServiceRequest const&, Aws::Http::HttpMethod, char const*, char const*, char const*) const (in /home/fantasy/next/cpp-graphql-server/build/cpp-graphql-server)
==12586== 
==12586== LEAK SUMMARY:
==12586==    definitely lost: 672 bytes in 4 blocks
==12586==    indirectly lost: 1,056 bytes in 4 blocks
==12586==      possibly lost: 0 bytes in 0 blocks
==12586==    still reachable: 6,504 bytes in 151 blocks
==12586==         suppressed: 0 bytes in 0 blocks
==12586== Reachable blocks (those to which a pointer was found) are not shown.
==12586== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==12586== 
==12586== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

Expected Behavior

no memory leak

Current Behavior

memory leak

Reproduction Steps

At present, I put the query operation into the thread, But it seems to have a memory leak

		m_options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Info;
		m_options.loggingOptions.logger_create_fn = [] {
			return Aws::MakeShared<Aws::Utils::Logging::ConsoleLogSystem>("console_logger", Aws::Utils::Logging::LogLevel::Info);
		};
		Aws::InitAPI(m_options);
		Aws::Client::ClientConfiguration config;
		config.region = region;
		config.scheme = Aws::Http::Scheme::HTTP;
		config.endpointOverride = endpoint;
		Aws::Auth::AWSCredentials aws_credentials{access_key_id, secret_key};
		m_dynamo_db_client_ptr = std::make_unique<Aws::DynamoDB::DynamoDBClient>(aws_credentials, config);

		std::thread([&] {
			Aws::DynamoDB::Model::ListTablesRequest list_tables_request;
			list_tables_request.SetLimit(50);
			const auto& list_tables_outcome = m_dynamo_db_client_ptr->ListTables(list_tables_request);
		}).detach();
		std::thread([&] {
			Aws::DynamoDB::Model::ListTablesRequest list_tables_request;
			list_tables_request.SetLimit(50);
			const auto& list_tables_outcome = m_dynamo_db_client_ptr->ListTables(list_tables_request);
		}).detach();

Aws::ShutdownAPI(m_options

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

the latest version

Compiler and Version used

g++11

Operating System and version

centos7

@nqf nqf added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 10, 2022
@nqf
Copy link
Author

nqf commented Jun 10, 2022

#1792

@jmklix
Copy link
Member

jmklix commented Jun 16, 2022

Looking into the cause of this. As mentioned in the issue you linked it looks like it might be something with when s2n_cleanup is called

@jmklix jmklix added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 16, 2022
@jmklix jmklix self-assigned this Jun 16, 2022
@nqf
Copy link
Author

nqf commented Jun 16, 2022

Looking into the cause of this. As mentioned in the issue you linked it looks like it might be something with when s2n_cleanup is called

Yes we need to call it,but why not call it in the library

@nqf nqf closed this as completed Jul 17, 2022
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@jmklix
Copy link
Member

jmklix commented May 1, 2023

The source of this has been fixed with this PR. Updating this sdk to version 1.11.62 or greater will remove the need to call s2n_cleanup.

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. investigating This issue is being investigated and/or work is in progress to resolve the issue.
Projects
None yet
Development

No branches or pull requests

2 participants