summaryrefslogtreecommitdiff
path: root/lib/zlog.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2021-05-03 11:17:36 -0400
committerGitHub <noreply@github.com>2021-05-03 11:17:36 -0400
commitf71e1ff6a98d0e244c7da11d870d14e31b517811 (patch)
tree0657d1718fa1018c0e8aa3bea76266f9dd6677ad /lib/zlog.c
parent92046e65409fe0ba2935e886cfb778253d5d8d4e (diff)
parent4f1a6d98da0703b066a1ae92dcac7c8f6ae3b1e6 (diff)
Merge pull request #8545 from opensourcerouting/assert-our-own
*: make our own assert() actually work
Diffstat (limited to 'lib/zlog.c')
-rw-r--r--lib/zlog.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/zlog.c b/lib/zlog.c
index a99fd71f0d..89ab9265d1 100644
--- a/lib/zlog.c
+++ b/lib/zlog.c
@@ -526,6 +526,36 @@ void zlog_sigsafe(const char *text, size_t len)
}
}
+void _zlog_assert_failed(const struct xref_assert *xref, const char *extra, ...)
+{
+ va_list ap;
+ static bool assert_in_assert; /* "global-ish" variable, init to 0 */
+
+ if (assert_in_assert)
+ abort();
+ assert_in_assert = true;
+
+ if (extra) {
+ struct va_format vaf;
+
+ va_start(ap, extra);
+ vaf.fmt = extra;
+ vaf.va = &ap;
+
+ zlog(LOG_CRIT,
+ "%s:%d: %s(): assertion (%s) failed, extra info: %pVA",
+ xref->xref.file, xref->xref.line, xref->xref.func,
+ xref->expr, &vaf);
+
+ va_end(ap);
+ } else
+ zlog(LOG_CRIT, "%s:%d: %s(): assertion (%s) failed",
+ xref->xref.file, xref->xref.line, xref->xref.func,
+ xref->expr);
+
+ /* abort() prints backtrace & memstats in SIGABRT handler */
+ abort();
+}
int zlog_msg_prio(struct zlog_msg *msg)
{