]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
mem: checkfree assertion after debug list dump
authorColin Vidal <colin@isc.org>
Fri, 17 Oct 2025 08:54:09 +0000 (10:54 +0200)
committerColin Vidal <colin@isc.org>
Sun, 19 Oct 2025 07:05:09 +0000 (09:05 +0200)
When a memory context is destroyed, if the `checkfree` property is set,
the program assert there is no remaining allocation. If there are and
assertions are enabled, the program immediately stops.

However, if memory trace/record debug is enabled, the dump of
outstanding allocation won't be printed as it is done after the
no remaining allocation assertion check.

This moves the no remaining allocation assertion check after the dump of
outstanding allocations, so it is still possible to figure out what's
still allocated by this memory context.

lib/isc/mem.c

index d06a8dbb645917abd119d76ae12890072bdc42ad..11d93f3ed65bad628645810790c742fa667fbb87 100644 (file)
@@ -553,14 +553,6 @@ mem_destroy(isc_mem_t *ctx) {
        ISC_LIST_UNLINK(contexts, ctx, link);
        UNLOCK(&contextslock);
 
-       if (ctx->checkfree) {
-               INSIST(isc_mem_inuse(ctx) == 0);
-       }
-
-       ctx->magic = 0;
-
-       INSIST(ISC_LIST_EMPTY(ctx->pools));
-
 #if ISC_MEM_TRACKLINES
        if (ctx->debuglist != NULL) {
                for (size_t i = 0; i < DEBUG_TABLE_COUNT; i++) {
@@ -582,6 +574,14 @@ mem_destroy(isc_mem_t *ctx) {
        }
 #endif /* if ISC_MEM_TRACKLINES */
 
+       if (ctx->checkfree) {
+               INSIST(isc_mem_inuse(ctx) == 0);
+       }
+
+       ctx->magic = 0;
+
+       INSIST(ISC_LIST_EMPTY(ctx->pools));
+
        free(ctx->name);
 
        isc_mutex_destroy(&ctx->lock);