BUG/MAJOR: Use -fwrapv.

Haproxy relies on signed integer wraparound on overflow, however this is
really an undefined behavior, so the C compiler is allowed to do whatever
it wants, and clang does exactly that, and that causes problems when the
timer goes from <= INT_MAX to > INT_MAX, and explains the various hangs
reported on FreeBSD every 49.7 days. To make sure we get the intended
behavior, use -fwrapv for now. A proper fix is to switch everything to
unsigned, and it will happen later, but this is simpler, and more likely to
be backported to the stable branches.
Many thanks to David King, Mark S, Dave Cottlehuber, Slawa Olhovchenkov,
Piotr Pawel Stefaniak, and any other I may have forgotten for reporting that
and investigating.
This commit is contained in:
Olivier Houchard 2017-04-19 11:34:10 +02:00 committed by Willy Tarreau
parent b83dc3d2ef
commit 73bdb325ed
1 changed files with 4 additions and 1 deletions

View File

@ -131,7 +131,10 @@ DEBUG_CFLAGS = -g
#### Compiler-specific flags that may be used to disable some negative over- #### Compiler-specific flags that may be used to disable some negative over-
# optimization or to silence some warnings. -fno-strict-aliasing is needed with # optimization or to silence some warnings. -fno-strict-aliasing is needed with
# gcc >= 4.4. # gcc >= 4.4.
SPEC_CFLAGS = -fno-strict-aliasing -Wdeclaration-after-statement # We rely on signed integer wraparound on overflow, however clang think it
# can do whatever it wants since it's an undefined behavior, so use -fwrapv
# to be sure we get the intended behavior.
SPEC_CFLAGS = -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv
#### Memory usage tuning #### Memory usage tuning
# If small memory footprint is required, you can reduce the buffer size. There # If small memory footprint is required, you can reduce the buffer size. There