From 9fdb85417467d85ab213f5e689b8693ebdb81f7f Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 30 Jul 2018 03:09:22 +0700 Subject: 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 --- src/hlr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 main(int argc, char **argv) { 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 @@ int main(int argc, char **argv) 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; } -- cgit v1.2.3