BUG/MINOR: wdt/debug: avoid signal re-entrance between debugger and watchdog
authorWilly Tarreau <w@1wt.eu>
Fri, 4 Apr 2025 15:20:25 +0000 (17:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Apr 2025 15:04:35 +0000 (17:04 +0200)
commitf4c2b370d6da679e1d2d5ccc238ddabaea0f2508
tree338d23bbfce636afcdaeac1ec12ab7480cdb8d94
parentf668b85ecea96218c24524d91b7d4f1e065fcd74
BUG/MINOR: wdt/debug: avoid signal re-entrance between debugger and watchdog

As seen in issue #2860, there are some situations where a watchdog could
trigger during the debug signal handler, and where similarly the debug
signal handler may trigger during the wdt handler. This is really bad
because it could trigger some deadlocks inside inner libc code such as
dladdr() or backtrace() since the code will not protect against re-
entrance but only against concurrent accesses.

A first attempt was made using ha_sigmask() but that's not always very
convenient because the second handler is called immediately after
unblocking the signal and before returning, leaving signal cascades in
backtrace. Instead, let's mark which signals to block at registration
time. Here we're blocking wdt/dbg for both signals, and optionally
SIGRTMAX if DEBUG_DEV is used as that one may also be used in this case.

This should be backported at least to 3.1.

(cherry picked from commit ebf1757dc26572578492d421e9905707b5e0ca7d)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/debug.c
src/wdt.c