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

Fix tls_ctx memleak in s3 client creation #822

Closed
wants to merge 1 commit into from
Closed

Conversation

praetp
Copy link
Contributor

@praetp praetp commented Aug 20, 2024

Reproduction scenario:

try(var tlsc = new TlsContext(); var c = new S3Client(new S3ClientOptions()
                    .withRegion("eu-west-1")
                    .withClientBootstrap(ClientBootstrap.getOrCreateStaticDefault())
                    .withTlsContext(tlsc)
            )) {
            }

--> this code will quickly go OOM without the fix in this commit

Issue #, if available:

Description of changes:
Make sure tls_ctx refcount is decremented by cleaning up tls_options.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@steven-aerts
Copy link

This will fix #823

@@ -521,7 +521,9 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientNew(
env, &proxy_options, jni_proxy_host, jni_proxy_authorization_username, jni_proxy_authorization_password);

aws_mem_release(aws_jni_get_allocator(), s3_tcp_keep_alive_options);

if (!tls_options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (tls_options) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course. Last minute change by me which I did not test :)

Will fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... fixed

Reproduction scenario:

```
try(var tlsc = new TlsContext(); var c = new S3Client(new S3ClientOptions()
                    .withRegion("eu-west-1")
                    .withClientBootstrap(ClientBootstrap.getOrCreateStaticDefault())
                    .withTlsContext(tlsc)
            )) {
            }
```

--> this code will quickly go OOM without the fix in this commit
@jmklix
Copy link
Member

jmklix commented Aug 23, 2024

This fix was merged here, along with test for memory leaks

@jmklix jmklix closed this Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants