MINOR: tinfo: add a new thread flag to indicate a call from a sig handler
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2025 15:26:24 +0000 (16:26 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 18 Mar 2025 15:13:34 +0000 (16:13 +0100)
commit685dbc44107298f725178e1e648d9959a1cf2a4f
tree9c4c669ce8ee237da5a6a65bc9599c2960102ed2
parent63a8e8802e357a3d1dc7ec7e3a50a402de568a0e
MINOR: tinfo: add a new thread flag to indicate a call from a sig handler

Signal handlers must absolutely not change anything, but some long and
complex call chains may look innocuous at first glance, yet result in
some subtle write accesses (e.g. pools) that can conflict with a running
thread being interrupted.

Let's add a new thread flag TH_FL_IN_SIG_HANDLER that is only set when
entering a signal handler and cleared when leaving them. Note, we're
speaking about real signal handlers (synchronous ones), not deferred
ones. This will allow some sensitive call places to act differently
when detecting such a condition, and possibly even to place a few new
BUG_ON().

(cherry picked from commit ddd173355c9c7452ff6ec317c8be6195d25dba2a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bc35f7763b413370f611c775e64acab469dead04)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
include/haproxy/tinfo-t.h
src/debug.c
src/signal.c
src/wdt.c