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)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Feb 2025 15:26:13 +0000 (16:26 +0100)
commitbc35f7763b413370f611c775e64acab469dead04
tree012cee8a658c8f2d819599c073e348f14f91a12c
parent0ce82061f72bf7f0c1341cdca2f9e90f03437aa4
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>
include/haproxy/tinfo-t.h
src/debug.c
src/signal.c
src/wdt.c