The trash pool is initialized twice in haproxy, first during STG_POOL,
and 2nd after configuration parsing.
Doing alloc_trash_chunk() between this 2 phases can lead to strange
things if we are using it after, indeed the pool is destroyed and
trying to do a free_trash_chunk() or accessing the pointer will lead to
crashes.
This patch checks that we don't have used buffers from the trash pool
before initializing the pool again.
/* Initialize the trash buffers. It returns 0 if an error occurred. */
int init_trash_buffers(int first)
{
+ BUG_ON(!first && pool_used(pool_head_trash) > 0); /* we tried to keep a trash buffer after reinit the pool */
pool_destroy(pool_head_trash);
pool_head_trash = create_pool("trash",
sizeof(struct buffer) + global.tune.bufsize,