<p>Vadim Yanitskiy has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/10224">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">hlr.c: track the use of talloc NULL memory contexts<br><br>Tracking NULL memory contexts allows one to detect memory chunks<br>allocated outside the application's root context, which in most<br>cases are the result of some mistake.<br><br>For example, the VTY implementation still uses the NULL context,<br>so we have to clean up it manually until this is fixed.<br><br>At the moment we have at least one chunk allocated outside the<br>application's root context (excluding the VTY context):<br><br>  full talloc report on 'null_context' (total 24 bytes in 2 blocks)<br>    struct lookup_helper  contains  24 bytes in  1 blocks<br><br>Change-Id: I7ea86730e090c06b2a5966ae4d04b8144b1cd20a<br>---<br>M src/hlr.c<br>1 file changed, 13 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/24/10224/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/hlr.c b/src/hlr.c</span><br><span>index 6c0cb0a..8732587 100644</span><br><span>--- a/src/hlr.c</span><br><span>+++ b/src/hlr.c</span><br><span>@@ -551,6 +551,9 @@</span><br><span> {</span><br><span>      int rc;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+   /* Track the use of talloc NULL memory contexts */</span><br><span style="color: hsl(120, 100%, 40%);">+    talloc_enable_null_tracking();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR");</span><br><span>  msgb_talloc_ctx_init(hlr_ctx, 0);</span><br><span>    vty_info.tall_ctx = hlr_ctx;</span><br><span>@@ -632,5 +635,15 @@</span><br><span>  talloc_report_full(hlr_ctx, stderr);</span><br><span>         talloc_free(hlr_ctx);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+     /* FIXME: VTY code still uses NULL-context */</span><br><span style="color: hsl(120, 100%, 40%);">+ talloc_free(tall_vty_ctx);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /**</span><br><span style="color: hsl(120, 100%, 40%);">+    * Report the heap state of NULL context, then free,</span><br><span style="color: hsl(120, 100%, 40%);">+   * so both ASAN and Valgrind are happy...</span><br><span style="color: hsl(120, 100%, 40%);">+      */</span><br><span style="color: hsl(120, 100%, 40%);">+   talloc_report_full(NULL, stderr);</span><br><span style="color: hsl(120, 100%, 40%);">+     talloc_disable_null_tracking();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>    return 0;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10224">change 10224</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/10224"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-hlr </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I7ea86730e090c06b2a5966ae4d04b8144b1cd20a </div>
<div style="display:none"> Gerrit-Change-Number: 10224 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>