On Mon, 16 Mar 2026 16:46:28 +1100
David Gibson
+++ b/util.h @@ -73,10 +73,14 @@ void abort_with_msg(const char *fmt, ...) * Therefore, avoid using the usual do while wrapper we use to force the macro * to act like a single statement requiring a ';'. */ -#define ASSERT_WITH_MSG(expr, ...) \ +#define assert_with_msg(expr, ...) \ ((expr) ? (void)0 : abort_with_msg(__VA_ARGS__)) -#define ASSERT(expr) \ - ASSERT_WITH_MSG((expr), "ASSERTION FAILED in %s (%s:%d): %s", \ +/* The standard library assert() hits our seccomp filter and dies before it can + * actually print a message. So, replace it with our own version. + */ +#undef assert +#define assert(expr) \ + assert_with_msg((expr), "ASSERTION FAILED in %s (%s:%d): %s", \ __func__, __FILE__, __LINE__, STRINGIFY(expr))
While looking this up to make sure it's specified as a macro (it is,
and this builds against musl as well), I realised that POSIX.1-2024
says:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/assert.html
Forcing a definition of the name NDEBUG, either from the compiler
command line or with the preprocessor control statement #define NDEBUG
ahead of the #include