]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: prevent gcc from moving empty keywords lists into BSS
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Jun 2013 21:16:39 +0000 (23:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Jun 2013 21:29:02 +0000 (23:29 +0200)
commitdc13c11c1e1e4888227a291e5eac7156e057b27a
tree24e222d7f933c3190d1f2ce43650bce5c05716fa
parent8615c2af67dc2be07bdb246ed13130fe7d32e3d1
BUG/MEDIUM: prevent gcc from moving empty keywords lists into BSS

Benoit Dolez reported a failure to start haproxy 1.5-dev19. The
process would immediately report an internal error with missing
fetches from some crap instead of ACL names.

The cause is that some versions of gcc seem to trim static structs
containing a variable array when moving them to BSS, and only keep
the fixed size, which is just a list head for all ACL and sample
fetch keywords. This was confirmed at least with gcc 3.4.6. And we
can't move these structs to const because they contain a list element
which is needed to link all of them together during the parsing.

The bug indeed appeared with 1.5-dev19 because it's the first one
to have some empty ACL keyword lists.

One solution is to impose -fno-zero-initialized-in-bss to everyone
but this is not really nice. Another solution consists in ensuring
the struct is never empty so that it does not move there. The easy
solution consists in having a non-null list head since it's not yet
initialized.

A new "ILH" list head type was thus created for this purpose : create
an Initialized List Head so that gcc cannot move the struct to BSS.
This fixes the issue for this version of gcc and does not create any
burden for the declarations.
14 files changed:
include/common/mini-clist.h
src/acl.c
src/backend.c
src/compression.c
src/dumpstats.c
src/frontend.c
src/listener.c
src/payload.c
src/proto_http.c
src/proto_tcp.c
src/proxy.c
src/sample.c
src/session.c
src/ssl_sock.c