]> git.kaiwu.me - haproxy.git/commitdiff
BUILD: quic: workaround a gcc bug saying "maybe used uninitialized" when USE_TRACE=0
authorWilly Tarreau <w@1wt.eu>
Wed, 1 Jul 2026 13:09:10 +0000 (15:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Jul 2026 14:32:28 +0000 (16:32 +0200)
In quic_transport_params_store(), we call qc_early_transport_params_cpy()
if edata_accepted is set, which copies one by one all tx_params into the
locally allocated etps struct, and later after updates we call
qc_early_transport_params_validate() to check if they changed. It turns
out that when USE_TRACE is disabled, gcc 4 to 13 are confused and believe
that one or several of the fields compared in the later function might be
used uninitialized. A careful code inspection proves that this is not the
case. Setting them to zero in the _cpy() function makes the warning
disappear, it's really an issue related to variable propagation it seems,
which can explain why it doesn't happen with traces (code is a bit more
complex). Gcc-13 only emits a warning about a single field, and gcc-14
completely solved it. Playing with consts, __maybe_unused etc has no
effect.

One thing works however, it is to mark the _validate() function noinline.
In this case it is implemented normally and the compiler doesn't put its
nose into the propagation path and doesn't complain.

Such comments are always scary because one may seriously wonder whether
the compiler emits valid code when it says this...

It should be backported to 3.4 which experiences the same warning with
USE_TRACE=0.

src/quic_tp.c

index b38c5318ac7ad0ba7d8261fc4c36735d3211567a..1b6d1015ffa58d200b9626751d48b1cf1c6acbee 100644 (file)
@@ -937,6 +937,11 @@ void qc_early_transport_params_reuse(struct quic_conn *qc,
        TRACE_PROTO("\nTX(remote) transp. params.", QUIC_EV_TRANSP_PARAMS, qc, p);
 }
 
+// noinline: workaround a gcc 4-13 bug reporting "maybe used uninitialized" on
+// some fields of *e when called from quic_transport_params_store() despite
+// being set early via qc_early_transport_params_cpy(). Reproducible with
+// USE_TRACE=0. gcc<13 has many warnings. 13 has a single one, 14 is OK.
+__attribute__((noinline))
 static int qc_early_tranport_params_validate(struct quic_conn *qc,
                                              struct quic_transport_params *p,
                                              struct quic_early_transport_params *e)