From c12bf9af0b7f134c0cf831a4d94a5d2bcd9f9b71 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 11 Jun 2021 07:31:57 +0200 Subject: [PATCH] BUG/MEDIUM: errors: include missing obj_type file A tiny change in commit 6af81f80f ("MEDIUM: errors: implement parsing context type") triggered an awful bug in gcc 5 and below (4.7.4 to 5.5 confirmed affected, at least on aarch64/mips/x86_64) causing the startup to loop forever in acl_find_target(). This was tracked down to the acl.c file seeing a different definition of the struct proxy than other files. The reason for this is that it sees an unpacked "enum obj_type" (4 bytes) while others see it packed (1 byte), thus all fields in the struct are having a different alignment, and the "acl" list is shifted one pointer to the next struct and seems to loop onto itself. The commit above did nothing more than adding "enum obj_type *obj" in a new struct without including obj_type.h, and that was apparently enough for the compiler to internally declare obj_type as a regular enum and silently ignore the packed attribute that it discovers later, so depending on the order of includes, some files would see it as 1 byte and others as 4. This patch simply adds the missing include but due to the nature of the bug, probably that creating a special "packed_enum" definition to disable the packed attribute on such compilers could be a safer option. No backport is needed as this is only in -dev. --- include/haproxy/errors.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/haproxy/errors.h b/include/haproxy/errors.h index a6c1177..bebad84 100644 --- a/include/haproxy/errors.h +++ b/include/haproxy/errors.h @@ -26,6 +26,7 @@ #include #include +#include /* These flags may be used in various functions which are called from within * loops (eg: to start all listeners from all proxies). They provide enough -- 1.7.10.4