Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/10224 )

Change subject: hlr.c: track the use of talloc NULL memory contexts
......................................................................

hlr.c: track the use of talloc NULL memory contexts

Tracking NULL memory contexts allows one to detect memory chunks
allocated outside the application's root context, which in most
cases are the result of some mistake.

For example, the VTY implementation still uses the NULL context,
so we have to clean up it manually until this is fixed.

At the moment we have at least one chunk allocated outside the
application's root context (excluding the VTY context):

  full talloc report on 'null_context' (total 24 bytes in 2 blocks)
    struct lookup_helper  contains  24 bytes in  1 blocks

Change-Id: I7ea86730e090c06b2a5966ae4d04b8144b1cd20a
---
M src/hlr.c
1 file changed, 13 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/hlr.c b/src/hlr.c
index 6c0cb0a..8732587 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -551,6 +551,9 @@
 {
        int rc;

+       /* Track the use of talloc NULL memory contexts */
+       talloc_enable_null_tracking();
+
        hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR");
        msgb_talloc_ctx_init(hlr_ctx, 0);
        vty_info.tall_ctx = hlr_ctx;
@@ -632,5 +635,15 @@
        talloc_report_full(hlr_ctx, stderr);
        talloc_free(hlr_ctx);

+       /* FIXME: VTY code still uses NULL-context */
+       talloc_free(tall_vty_ctx);
+
+       /**
+        * Report the heap state of NULL context, then free,
+        * so both ASAN and Valgrind are happy...
+        */
+       talloc_report_full(NULL, stderr);
+       talloc_disable_null_tracking();
+
        return 0;
 }

--
To view, visit https://gerrit.osmocom.org/10224
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7ea86730e090c06b2a5966ae4d04b8144b1cd20a
Gerrit-Change-Number: 10224
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder

Reply via email to