Found memory leak while we run ASAN test. It should be something introduced recently. I already found one fix as #360 . However there are still some more leaks even after applying #360. List the ASAN report here. The line number may be different to tls13-prototype branch as we apply our local patches.
=================================================================
==3474879==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 416 byte(s) in 1 object(s) allocated from:
#0 0x1ab37c7 in calloc (/data/users/lhuang04/fbsource/fbcode/buck-out/dbg/cells/fbsource/gen/aab7ed39/xplat/mobilenetwork/test/test+0x1ab37c7)
#1 0x1690126 in gcm_ctx_alloc xplat/mobilenetwork/third-party/mbedtls/library/cipher_wrap.c:83
#2 0x168d2a0 in mbedtls_cipher_setup xplat/mobilenetwork/third-party/mbedtls/library/cipher.c:222
#3 0x110b647 in mbedtls_ssl_tls13_populate_transform xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_generic.c:2064
#4 0x10f56d9 in ssl_server_hello_postprocess xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:3380
#5 0x10e7e2e in ssl_server_hello_process xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:2864
#6 0x10e6b6c in mbedtls_ssl_handshake_client_step_tls1_3 xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:4175
#7 0x10dfd77 in mbedtls_ssl_handshake_step xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls.c:6090
#8 0x10dfed8 in mbedtls_ssl_handshake xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls.c:6166
Direct leak of 416 byte(s) in 1 object(s) allocated from:
#0 0x1ab37c7 in calloc (/data/users/lhuang04/fbsource/fbcode/buck-out/dbg/cells/fbsource/gen/aab7ed39/xplat/mobilenetwork/test/test+0x1ab37c7)
#1 0x1690126 in gcm_ctx_alloc xplat/mobilenetwork/third-party/mbedtls/library/cipher_wrap.c:83
#2 0x168d2a0 in mbedtls_cipher_setup xplat/mobilenetwork/third-party/mbedtls/library/cipher.c:222
#3 0x110b604 in mbedtls_ssl_tls13_populate_transform xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_generic.c:2057
#4 0x10f56d9 in ssl_server_hello_postprocess xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:3380
#5 0x10e7e2e in ssl_server_hello_process xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:2864
#6 0x10e6b6c in mbedtls_ssl_handshake_client_step_tls1_3 xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:4175
#7 0x10dfd77 in mbedtls_ssl_handshake_step xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls.c:6090
#8 0x10dfed8 in mbedtls_ssl_handshake xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls.c:6166
Indirect leak of 288 byte(s) in 1 object(s) allocated from:
#0 0x1ab37c7 in calloc (/data/users/lhuang04/fbsource/fbcode/buck-out/dbg/cells/fbsource/gen/aab7ed39/xplat/mobilenetwork/test/test+0x1ab37c7)
#1 0x1690056 in aes_ctx_alloc xplat/mobilenetwork/third-party/mbedtls/library/cipher_wrap.c:204
#2 0x168d2a0 in mbedtls_cipher_setup xplat/mobilenetwork/third-party/mbedtls/library/cipher.c:222
#3 0x16b7707 in mbedtls_gcm_setkey xplat/mobilenetwork/third-party/mbedtls/library/gcm.c:183
#4 0x16900fa in gcm_aes_setkey_wrap xplat/mobilenetwork/third-party/mbedtls/library/cipher_wrap.c:510
#5 0x168dca8 in mbedtls_cipher_setkey xplat/mobilenetwork/third-party/mbedtls/library/cipher.c:365
#6 0x110b9a8 in mbedtls_ssl_tls13_populate_transform xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_generic.c:2107
#7 0x10f56d9 in ssl_server_hello_postprocess xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:3380
#8 0x10e7e2e in ssl_server_hello_process xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:2864
#9 0x10e6b6c in mbedtls_ssl_handshake_client_step_tls1_3 xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:4175
#10 0x10dfd77 in mbedtls_ssl_handshake_step xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls.c:6090
#11 0x10dfed8 in mbedtls_ssl_handshake xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls.c:6166
Indirect leak of 288 byte(s) in 1 object(s) allocated from:
#0 0x1ab37c7 in calloc (/data/users/lhuang04/fbsource/fbcode/buck-out/dbg/cells/fbsource/gen/aab7ed39/xplat/mobilenetwork/test/test+0x1ab37c7)
#1 0x1690056 in aes_ctx_alloc xplat/mobilenetwork/third-party/mbedtls/library/cipher_wrap.c:204
#2 0x168d2a0 in mbedtls_cipher_setup xplat/mobilenetwork/third-party/mbedtls/library/cipher.c:222
#3 0x16b7707 in mbedtls_gcm_setkey xplat/mobilenetwork/third-party/mbedtls/library/gcm.c:183
#4 0x16900fa in gcm_aes_setkey_wrap xplat/mobilenetwork/third-party/mbedtls/library/cipher_wrap.c:510
#5 0x168db1d in mbedtls_cipher_setkey xplat/mobilenetwork/third-party/mbedtls/library/cipher.c:360
#6 0x110b8e3 in mbedtls_ssl_tls13_populate_transform xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_generic.c:2099
#7 0x10f56d9 in ssl_server_hello_postprocess xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:3380
#8 0x10e7e2e in ssl_server_hello_process xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:2864
#9 0x10e6b6c in mbedtls_ssl_handshake_client_step_tls1_3 xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls13_client.c:4175
#10 0x10dfd77 in mbedtls_ssl_handshake_step xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls.c:6090
#11 0x10dfed8 in mbedtls_ssl_handshake xplat/mobilenetwork/third-party/mbedtls/library/ssl_tls.c:6166
SUMMARY: AddressSanitizer: 1408 byte(s) leaked in 4 allocation(s).
System information
Mbed TLS version (number or commit id):
Operating system and version:
Configuration (if not default, please attach mbedtls_config.h):
Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
Additional environment information:
Summary
Found memory leak while we run ASAN test. It should be something introduced recently. I already found one fix as #360 . However there are still some more leaks even after applying #360. List the ASAN report here. The line number may be different to
tls13-prototype
branch as we apply our local patches.System information
Mbed TLS version (number or commit id): Operating system and version: Configuration (if not default, please attach
mbedtls_config.h
): Compiler and options (if you used a pre-built binary, please indicate how you obtained it): Additional environment information:Expected behavior
Actual behavior
Steps to reproduce
Additional information