]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: debug: only dump the trace once in __BUG_ON_ONCE()
authorWilly Tarreau <w@1wt.eu>
Fri, 7 Aug 2026 13:06:53 +0000 (15:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Aug 2026 13:06:53 +0000 (15:06 +0200)
Amaury found that CHECK_IF() was dumping the stack trace on each call,
which was not the intent. The reason is that complain() performs the
check on the counter, but the decision to dump the stack later is based
on the choice between aborting and dumping. Let's break out of this when
the count is > 1. Under high concurrency it can cause a trace never to
be emitted but this is a detail. The whole thing needs to be redone
more cleanly anyway.

This should be backported to 2.6.

include/haproxy/bug.h

index bb1fc0147d6a5e5dd0b40dfb115f60b43030b161..2f4c77543cc194db695ff4c53551c7d36d60e11b 100644 (file)
@@ -335,6 +335,8 @@ extern __attribute__((__weak__)) struct debug_count __stop_dbg_cnt  HA_SECTION_S
                else                                                    \
                        msg = "\n" pfx "condition \"" #cond "\" matched at " file ":" #line "" sfx "\n"; \
                complain(&__match_count_##line, msg, crash);            \
+               if (_HA_ATOMIC_LOAD(&__match_count_##line) > 1)         \
+                       break;                                          \
                if (crash & 1)                                          \
                        ABORT_NOW();                                    \
                else                                                    \