From e18616168f76274861c1f0cb52ddb916043ac18d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 7 Jun 2019 15:33:06 +0200 Subject: [PATCH] Revert "MINOR: chunks: Make sure trash_size is only set once." This reverts commit 1c3b83242da96f1d94ef3df34c399c1b984668b6. It was made only to silence the thread sanitizer but ends up creating a bug. Indeed, if "tune.bufsize" is in the global section, the trash_size value is not updated anymore and the trash becomes smaller than a buffer! Let's stop trying to fix the thread sanitizer reports, they are invalid, and trying to fix them actually introduces bugs where there were none. See GH issue #117 for more context. No backport is needed. --- src/chunk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/chunk.c b/src/chunk.c index 344b28d20..8e77858c3 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -68,9 +68,8 @@ struct buffer *get_trash_chunk(void) */ static int alloc_trash_buffers(int bufsize) { - int old = 0; chunk_init(&trash, my_realloc2(trash.area, bufsize), bufsize); - HA_ATOMIC_CAS(&trash_size, &old, bufsize); + trash_size = bufsize; trash_buf1 = (char *)my_realloc2(trash_buf1, bufsize); trash_buf2 = (char *)my_realloc2(trash_buf2, bufsize); return trash.area && trash_buf1 && trash_buf2;