]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: debug: support passing an optional message in ABORT_NOW()
authorWilly Tarreau <w@1wt.eu>
Mon, 5 Feb 2024 15:16:08 +0000 (16:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 5 Feb 2024 16:09:00 +0000 (17:09 +0100)
commitd417863828a4704fc63023e53d6c74545fbf5d1b
tree1fd12ec9c571ddb923dd7d62e9a064b1520c982d
parent73705ac701c6b0a8201ae29fffd9f29520a03b78
MINOR: debug: support passing an optional message in ABORT_NOW()

The ABORT_NOW() macro is not much used since we have BUG_ON(), but
there are situations where it makes sense, typically if the program
must always die regardless od DEBUG_STRICT, or if the condition must
always be evaluated (e.g. decompress something and check it).

It's not convenient not to have any hint about what happened there. But
providing too much info also results in wiping some registers, making
the trace less exploitable, so a compromise must be found.

What this patch does is to provide the support for an optional argument
to ABORT_NOW(). When an argument is passed (a string), then a message
will be emitted with the file name, line number, the message and a
trailing LF, before the stack dump and the crash. It should be used
reasonably, for example in functions that have multiple calls that need
to be more easily distinguished.
include/haproxy/bug.h