Skip to content

Commit 0bfd36e

Browse files
committed
MINOR: chunk: add a BUG_ON upon the next init_trash_buffer()
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.
1 parent 5f37af7 commit 0bfd36e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/chunk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static void free_trash_buffers_per_thread()
8989
/* Initialize the trash buffers. It returns 0 if an error occurred. */
9090
int init_trash_buffers(int first)
9191
{
92+
BUG_ON(!first && pool_used(pool_head_trash) > 0); /* we tried to keep a trash buffer after reinit the pool */
9293
pool_destroy(pool_head_trash);
9394
pool_head_trash = create_pool("trash",
9495
sizeof(struct buffer) + global.tune.bufsize,

0 commit comments

Comments
 (0)