]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: debug: fix a small race in the thread dumping code
authorWilly Tarreau <w@1wt.eu>
Wed, 31 Jul 2019 17:15:45 +0000 (19:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 31 Jul 2019 17:35:31 +0000 (19:35 +0200)
commitc07736209db764fb2aef6f18ed3687a504c35771
tree341c24f929cc64e4b83caea2bc573c653affe3d8
parenta8c73748f8ca545296a8b47f3fd3950dfcc75737
BUG/MINOR: debug: fix a small race in the thread dumping code

If a thread dump is requested from a signal handler, it may interrupt
a thread already waiting for a dump to complete, and may see the
threads_to_dump variable go to zero while others are waiting, steal
the lock and prevent other threads from ever completing. This tends
to happen when dumping many threads upon a watchdog timeout, to threads
waiting for their turn.

Instead now we proceed in two steps :
  1) the last dumped thread sets all bits again
  2) all threads only wait for their own bit to appear, then clear it
     and quit

This way there's no risk that a bit performs a double flip in the same
loop and threads cannot get stuck here anymore.

This should be backported to 2.0 as it clarifies stack traces.
src/debug.c