diff --git a/include/haproxy/pool.h b/include/haproxy/pool.h index 9b8084205..9aec880bc 100644 --- a/include/haproxy/pool.h +++ b/include/haproxy/pool.h @@ -62,6 +62,13 @@ *(typeof(pool)*)(((char *)__i) + __p->size) = __p; \ } while (0) +# define POOL_DEBUG_RESET_MARK(pool, item) \ + do { \ + typeof(pool) __p = (pool); \ + typeof(item) __i = (item); \ + *(typeof(pool)*)(((char *)__i) + __p->size) = __builtin_return_address(0); \ + } while (0) + # define POOL_DEBUG_CHECK_MARK(pool, item) \ do { \ typeof(pool) __p = (pool); \ @@ -74,6 +81,7 @@ # define POOL_EXTRA_MARK (0) # define POOL_DEBUG_SET_MARK(pool, item) do { } while (0) +# define POOL_DEBUG_RESET_MARK(pool, item) do { } while (0) # define POOL_DEBUG_CHECK_MARK(pool, item) do { } while (0) #endif // DEBUG_MEMORY_POOLS diff --git a/src/pool.c b/src/pool.c index 8d9c17fd5..cc92245c7 100644 --- a/src/pool.c +++ b/src/pool.c @@ -653,6 +653,7 @@ void __pool_free(struct pool_head *pool, void *ptr) #endif /* we'll get late corruption if we refill to the wrong pool or double-free */ POOL_DEBUG_CHECK_MARK(pool, ptr); + POOL_DEBUG_RESET_MARK(pool, ptr); if (unlikely(mem_poison_byte >= 0)) memset(ptr, mem_poison_byte, pool->size);