[gnutls-devel] GnuTLS | gnutls_global_deinit() doesn't free all memory after loading system trusted CAs (#1070)
Read-only notification of GnuTLS library development activities
gnutls-devel at lists.gnutls.org
Wed Aug 19 17:31:20 CEST 2020
Miroslav Lichvar created an issue: https://gitlab.com/gnutls/gnutls/-/issues/1070
## Description of problem:
According to the documentation, calling `gnutls_global_deinit()` in an environment with `GNUTLS_NO_EXPLICIT_INIT=1` (or program compiled with `GNUTLS_SKIP_GLOBAL_INIT`) is supposed to free all memory used by gnutls. This doesn't seem to happen in my application, which is normally expected to make a few TLS sessions on start and then run for a long time without TLS. Maybe my program is buggy (see the reproducer), or there is a way to force gnutls to deallocate the memory, but I couldn't find it.
## Version of gnutls used:
gnutls-3.6.14
## Distributor of gnutls (e.g., Ubuntu, Fedora, RHEL)
Fedora 32
## How reproducible:
Always
Steps to Reproduce:
* compile and run the following program in valgrind:
```
#include <gnutls/gnutls.h>
GNUTLS_SKIP_GLOBAL_INIT
int main() {
gnutls_certificate_credentials_t credentials = NULL;
gnutls_global_init();
gnutls_certificate_allocate_credentials(&credentials);
gnutls_certificate_set_x509_system_trust(credentials);
gnutls_certificate_free_credentials(credentials);
gnutls_global_deinit();
return 0;
}
```
## Actual results:
```
...
==2640878== by 0x5CDE3F6: ??? (in /usr/lib64/pkcs11/p11-kit-trust.so)
==2640878== by 0x5CD9CE4: ??? (in /usr/lib64/pkcs11/p11-kit-trust.so)
==2640878== by 0x490DDD1: ??? (in /usr/lib64/libgnutls.so.30.28.0)
==2640878== by 0x490FE3E: ??? (in /usr/lib64/libgnutls.so.30.28.0)
==2640878== by 0x4910BFF: gnutls_pkcs11_obj_list_import_url4 (in /usr/lib64/libgnutls.so.30.28.0)
==2640878== by 0x4910D59: gnutls_pkcs11_obj_list_import_url3 (in /usr/lib64/libgnutls.so.30.28.0)
==2640878== by 0x49686C3: gnutls_x509_trust_list_add_trust_file (in /usr/lib64/libgnutls.so.30.28.0)
==2640878== by 0x48D9E70: gnutls_x509_trust_list_add_system_trust (in /usr/lib64/libgnutls.so.30.28.0)
==2640878== by 0x4010A5: main (in /home/miros/a.out)
==2640878==
==2640878== LEAK SUMMARY:
==2640878== definitely lost: 0 bytes in 0 blocks
==2640878== indirectly lost: 0 bytes in 0 blocks
==2640878== possibly lost: 0 bytes in 0 blocks
==2640878== still reachable: 5,408,309 bytes in 44,429 blocks
==2640878== suppressed: 0 bytes in 0 blocks
==2640878==
==2640878== For lists of detected and suppressed errors, rerun with: -s
==2640878== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```
## Expected results:
All memory freed.
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/issues/1070
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20200819/7d248b2c/attachment.html>
More information about the Gnutls-devel
mailing list