From b21aaef4e582758d085a59984d33901e74983a18 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 12 Apr 2024 15:56:18 +0200 Subject: [PATCH] DEBUG: pool: improve decoding of corrupted pools When a corruption was detected in an object, it's often said that the tag doesn't match the pool, but it should also check if it matches the location of an earlier pool_free() call, which happens when -dMcaller is used. That's what we're doing now. --- src/pool.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pool.c b/src/pool.c index ccee8c4be..65751b0dc 100644 --- a/src/pool.c +++ b/src/pool.c @@ -1016,9 +1016,16 @@ void pool_inspect_item(const char *msg, struct pool_head *pool, const void *item if (!the_pool) { const char *start, *end, *p; - pool_mark = (const void **)(((char *)item) + pool->size); chunk_appendf(&trash, - "Tag does not match any other pool.\n" + "Tag does not match any other pool.\n"); + + pool_mark = (const void **)(((char *)item) + pool->size); + if (resolve_sym_name(&trash, "Resolving the tag as a pool_free() location: ", *pool_mark)) + chunk_appendf(&trash, "\n"); + else + chunk_appendf(&trash, " (no match).\n"); + + chunk_appendf(&trash, "Contents around address %p+%lu=%p:\n", item, (ulong)((const void*)pool_mark - (const void*)item), pool_mark);