Change in osmo-hlr[master]: hlr.c: track the use of talloc NULL memory contexts

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Sun Jul 29 21:12:04 UTC 2018


Vadim Yanitskiy has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/24/10224/1

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: newchange
Gerrit-Change-Id: I7ea86730e090c06b2a5966ae4d04b8144b1cd20a
Gerrit-Change-Number: 10224
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180729/1fa345df/attachment.htm>


More information about the gerrit-log mailing list