<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>


<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">

<p class="details" style="font-style: italic; color: #777;">
<a href="https://gitlab.com/mlichvar">Miroslav Lichvar</a> created an issue <a href="https://gitlab.com/gnutls/gnutls/-/issues/1070">#1070</a>:
</p>
<div></div>
<h2 dir="auto">
<a id="user-content-description-of-problem" class="anchor" href="#description-of-problem" aria-hidden="true"></a>Description of problem:</h2>
<p dir="auto">According to the documentation, calling <code>gnutls_global_deinit()</code> in an environment with <code>GNUTLS_NO_EXPLICIT_INIT=1</code> (or program compiled with <code>GNUTLS_SKIP_GLOBAL_INIT</code>) 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.</p>
<h2 dir="auto">
<a id="user-content-version-of-gnutls-used" class="anchor" href="#version-of-gnutls-used" aria-hidden="true"></a>Version of gnutls used:</h2>
<p dir="auto">gnutls-3.6.14</p>
<h2 dir="auto">
<a id="user-content-distributor-of-gnutls-eg-ubuntu-fedora-rhel" class="anchor" href="#distributor-of-gnutls-eg-ubuntu-fedora-rhel" aria-hidden="true"></a>Distributor of gnutls (e.g., Ubuntu, Fedora, RHEL)</h2>
<p dir="auto">Fedora 32</p>
<h2 dir="auto">
<a id="user-content-how-reproducible" class="anchor" href="#how-reproducible" aria-hidden="true"></a>How reproducible:</h2>
<p dir="auto">Always</p>
<p dir="auto">Steps to Reproduce:</p>
<ul dir="auto">
<li>compile and run the following program in valgrind:</li>
</ul>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">#include <gnutls/gnutls.h></span>
<span id="LC2" class="line" lang="plaintext">GNUTLS_SKIP_GLOBAL_INIT</span>
<span id="LC3" class="line" lang="plaintext"></span>
<span id="LC4" class="line" lang="plaintext">int main() {</span>
<span id="LC5" class="line" lang="plaintext">  gnutls_certificate_credentials_t credentials = NULL;</span>
<span id="LC6" class="line" lang="plaintext"></span>
<span id="LC7" class="line" lang="plaintext">  gnutls_global_init();</span>
<span id="LC8" class="line" lang="plaintext">  gnutls_certificate_allocate_credentials(&credentials);</span>
<span id="LC9" class="line" lang="plaintext">  gnutls_certificate_set_x509_system_trust(credentials);</span>
<span id="LC10" class="line" lang="plaintext">  gnutls_certificate_free_credentials(credentials);</span>
<span id="LC11" class="line" lang="plaintext">  gnutls_global_deinit();</span>
<span id="LC12" class="line" lang="plaintext">  return 0;</span>
<span id="LC13" class="line" lang="plaintext">}</span></code></pre>
<h2 dir="auto">
<a id="user-content-actual-results" class="anchor" href="#actual-results" aria-hidden="true"></a>Actual results:</h2>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">...</span>
<span id="LC2" class="line" lang="plaintext">==2640878==    by 0x5CDE3F6: ??? (in /usr/lib64/pkcs11/p11-kit-trust.so)</span>
<span id="LC3" class="line" lang="plaintext">==2640878==    by 0x5CD9CE4: ??? (in /usr/lib64/pkcs11/p11-kit-trust.so)</span>
<span id="LC4" class="line" lang="plaintext">==2640878==    by 0x490DDD1: ??? (in /usr/lib64/libgnutls.so.30.28.0)</span>
<span id="LC5" class="line" lang="plaintext">==2640878==    by 0x490FE3E: ??? (in /usr/lib64/libgnutls.so.30.28.0)</span>
<span id="LC6" class="line" lang="plaintext">==2640878==    by 0x4910BFF: gnutls_pkcs11_obj_list_import_url4 (in /usr/lib64/libgnutls.so.30.28.0)</span>
<span id="LC7" class="line" lang="plaintext">==2640878==    by 0x4910D59: gnutls_pkcs11_obj_list_import_url3 (in /usr/lib64/libgnutls.so.30.28.0)</span>
<span id="LC8" class="line" lang="plaintext">==2640878==    by 0x49686C3: gnutls_x509_trust_list_add_trust_file (in /usr/lib64/libgnutls.so.30.28.0)</span>
<span id="LC9" class="line" lang="plaintext">==2640878==    by 0x48D9E70: gnutls_x509_trust_list_add_system_trust (in /usr/lib64/libgnutls.so.30.28.0)</span>
<span id="LC10" class="line" lang="plaintext">==2640878==    by 0x4010A5: main (in /home/miros/a.out)</span>
<span id="LC11" class="line" lang="plaintext">==2640878== </span>
<span id="LC12" class="line" lang="plaintext">==2640878== LEAK SUMMARY:</span>
<span id="LC13" class="line" lang="plaintext">==2640878==    definitely lost: 0 bytes in 0 blocks</span>
<span id="LC14" class="line" lang="plaintext">==2640878==    indirectly lost: 0 bytes in 0 blocks</span>
<span id="LC15" class="line" lang="plaintext">==2640878==      possibly lost: 0 bytes in 0 blocks</span>
<span id="LC16" class="line" lang="plaintext">==2640878==    still reachable: 5,408,309 bytes in 44,429 blocks</span>
<span id="LC17" class="line" lang="plaintext">==2640878==         suppressed: 0 bytes in 0 blocks</span>
<span id="LC18" class="line" lang="plaintext">==2640878== </span>
<span id="LC19" class="line" lang="plaintext">==2640878== For lists of detected and suppressed errors, rerun with: -s</span>
<span id="LC20" class="line" lang="plaintext">==2640878== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)</span></code></pre>
<h2 dir="auto">
<a id="user-content-expected-results" class="anchor" href="#expected-results" aria-hidden="true"></a>Expected results:</h2>
<p dir="auto">All memory freed.</p>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1070">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/-/sent_notifications/4fc2d2ea6c755663987dfe98ac1f96c7/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/1070"}}</script>


</p>
</div>
</body>
</html>