Skip to content

Memory leak caused by S3Client #2331

Closed
Closed

Description

@nrt9843

Describe the bug

Using the AWS S3Client causes a small memory leak, even in simple cases.

Expected Behavior

S3Client does not cause a memory leak when properly shut down.

Current Behavior

AddressSanitizer report:

==27159==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 144 byte(s) in 1 object(s) allocated from:
    #0 0x7f7b6240890f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x5588ebff77dc in CRYPTO_zalloc crypto/mem.c:197

Indirect leak of 512 byte(s) in 6 object(s) allocated from:
    #0 0x7f7b6240890f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x5588ebff77dc in CRYPTO_zalloc crypto/mem.c:197

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f7b6240890f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x5588ec039315 in OPENSSL_sk_deep_copy crypto/stack/stack.c:87

Indirect leak of 27 byte(s) in 2 object(s) allocated from:
    #0 0x7f7b6240890f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x5588ebff8fc9 in CRYPTO_strdup crypto/o_str.c:27

Indirect leak of 5 byte(s) in 1 object(s) allocated from:
    #0 0x7f7b6240890f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x5588ebff9102 in CRYPTO_strndup crypto/o_str.c:43

Indirect leak of 3 byte(s) in 1 object(s) allocated from:
    #0 0x7f7b62407720 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:85
    #1 0x5588ec002cf8 in ossl_provider_set_operation_bit crypto/provider_core.c:1627

SUMMARY: AddressSanitizer: 723 byte(s) leaked in 12 allocation(s).

Reproduction Steps

Here's a code snippet that reproduces the issue:

Aws::SDKOptions o;
Aws::InitAPI(o);
{
    Aws::Client::ClientConfiguration config;
    Aws::S3::S3Client client(config);
}
Aws::ShutdownAPI(o);

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

1.11.4

Compiler and Version used

gcc 12.1.0

Operating System and version

Ubuntu 22.04 (WSL)

Activity

  1. added
    bug
    needs-triage
    on Feb 2, 2023
  2. added
    p2
    and removed
    needs-triage
    on Feb 2, 2023
  3. jmklix commented on Feb 6, 2023

    @jmklix
    Member

    I don't see this memory leak on Mac. Going to try to repro on Ubuntu as well

  4. added
    investigating
    on Feb 6, 2023
  5. self-assigned this
    on Feb 6, 2023
  6. ank8690 commented on Feb 9, 2023

    @ank8690

    I also face this issue in AWS SDK Version 1.11.8 in Windows 10.

  7. kvpendergast commented on Feb 11, 2023

    @kvpendergast

    I'm using sdk version 2 and experiencing this issue. Here's the code:

    import AWS from 'aws-sdk'
    
    export const uploadImage = (key, blob) => {
      AWS.config.update({
        accessKeyId: process.env.AWS_ACCESS_KEY,
        secretAccessKey: process.env.AWS_SECRET_KEY,
      });
    
      const s3 = new AWS.S3({
        signatureVersion: 'v4',
        region: 'us-east-2'
      });
    
      return s3.upload({
        Bucket: 'my-bucket',
        Key: key,
        Body: blob,
        ContentType: 'image/png'
      }).promise()
    }
    
  8. jmklix commented on Feb 23, 2023

    @jmklix
    Member

    Able to repro this with Ubuntu 22.04

    ==6977== LEAK SUMMARY:
    ==6977==    definitely lost: 144 bytes in 1 blocks
    ==6977==    indirectly lost: 579 bytes in 11 blocks
    ==6977==      possibly lost: 0 bytes in 0 blocks
    ==6977==    still reachable: 1,507 bytes in 4 blocks
    ==6977==         suppressed: 0 bytes in 0 blocks
    ==6977== Reachable blocks (those to which a pointer was found) are not shown.
    ==6977== To see them, rerun with: --leak-check=full --show-leak-kinds=all
    

    Still working on finding the root cause and a fix for this

  9. added
    pending-release
    and removed
    investigating
    on Feb 28, 2023
  10. jmklix commented on Feb 28, 2023

    @jmklix
    Member

    The fix has been merged. You can get the latest updates from head or wait for tomorrow's release. Please let us know if you run into anymore memory leaks

  11. github-actions commented on Feb 28, 2023

    @github-actions

    ⚠️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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugp2pending-release

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions