]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: stream/debug: harden the stream dump function regarding signals
authorWilly Tarreau <w@1wt.eu>
Fri, 4 Sep 2026 12:43:15 +0000 (14:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 4 Sep 2026 13:12:54 +0000 (15:12 +0200)
commitc044fdbf47da904d0544a5eb43f8e80d5f502bef
tree22c825bd9765c81222e1cadfb1b00cbb67f1f12b
parent36a9541c635b0f1951903cdcae9647d2eb43cb24
BUG/MINOR: stream/debug: harden the stream dump function regarding signals

As seen in GH issue #3490, it is sometimes possible to see a stream in
an intermediate state during a dump (due to the dump being called by a
signal handler). The code was already designed in a defensive way for
this, but not sufficiently.

Indeed, while a stream my never be seen in a stable state with NULL in
any of its sedesc, there exist a short period during sc_reset_endp()
where the backend sedesc is NULL for a few nanoseconds, between the
NULL and the new value, and if a dump signal happens in the middle,
the __strm_dump_to_buffer() function will crash.

This patch modifies __strm_dump_to_buffer() so that the sc, sd and conns
are taken for each side when entering the function and used as tests every
time they're about to be dereferenced. This way certain fields will be
omitted whenever such situations happen.

This new version now resists heavy connection retries combined with
1ms warnings and two parallel "show threads" loops..

This should be backported to stable releases. It is likely that it will
not easily apply to all versions, so the changes might more easily be
re-done; the principle consists in conditioning the dereference of
sc->sedesc for each side (which also happens when reading flags).
src/stream.c