]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: make sure calls to ha_crash_now() are never merged
authorWilly Tarreau <w@1wt.eu>
Fri, 2 Feb 2024 16:05:36 +0000 (17:05 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 2 Feb 2024 16:12:06 +0000 (17:12 +0100)
As indicated in previous commit, we don't want calls to ha_crash_now()
to be merged, since it will make gdb return a wrong line number. This
was found to happen with gcc 4.7 and 4.8 in h3.c where 26 calls end up
as only 5 to 18 "ud2" instructions depending on optimizations. By
calling DO_NOT_FOLD() just before provoking the trap, we can reliably
avoid this folding problem. Note that this does not address the case
where abort() is used instead (DEBUG_USE_ABORT).

include/haproxy/bug.h

index c980727e7a0c9eabb36f79fd39be709ecf9c5863..24a38ff1728191d3400d725429a9465cf1ce7b50 100644 (file)
@@ -51,6 +51,7 @@
 #define ha_crash_now() do {                                            \
                /* ud2 opcode: 2 bytes, raises illegal instruction */   \
                __asm__ volatile(".byte 0x0f,0x0b\n");                  \
+               DO_NOT_FOLD();                                          \
                my_unreachable();                                       \
        } while (0)
 
@@ -58,6 +59,7 @@
 #define ha_crash_now() do {                                            \
                /* udf#imm16: 4 bytes (), raises illegal instruction */ \
                __asm__ volatile(".byte 0x00,0x00,0x00,0x00\n");        \
+               DO_NOT_FOLD();                                          \
                my_unreachable();                                       \
        } while (0)
 
@@ -77,6 +79,7 @@ static inline __attribute((always_inline)) void ha_crash_now(void)
 #if __GNUC_PREREQ__(5, 0)
 #pragma GCC diagnostic pop
 #endif
+       DO_NOT_FOLD();
        my_unreachable();
 }