]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: errors: include missing obj_type file
authorWilly Tarreau <w@1wt.eu>
Fri, 11 Jun 2021 05:31:57 +0000 (07:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 11 Jun 2021 05:43:07 +0000 (07:43 +0200)
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

index a6c11771410e8a729246d58e7aeaffd42c841726..bebad844af37fe21ad8637c77ff109cd071960ed 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdio.h>
 
 #include <haproxy/buf-t.h>
+#include <haproxy/obj_type-t.h>
 
 /* 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