--- assert.c.orig 2008-09-06 16:27:37.000000000 -0700 +++ assert.c 2008-09-07 01:35:02.000000000 -0700 @@ -41,20 +41,39 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/ass #include <stdio.h> #include <stdlib.h> +extern const char *__crashreporter_info__; +static const char badasprintf[] = + "Assertion failed and asprintf also failed to create full error string"; + void -__assert(func, file, line, failedexpr) +__assert_rtn(func, file, line, failedexpr) const char *func, *file; int line; const char *failedexpr; { - if (func == NULL) + char *str = NULL; + + if (func == NULL) { (void)fprintf(stderr, "Assertion failed: (%s), file %s, line %d.\n", failedexpr, file, line); - else + if (!__crashreporter_info__) { + asprintf(&str, + "Assertion failed: (%s), file %s, line %d.\n", + failedexpr, file, line); + __crashreporter_info__ = str ? str : badasprintf; + } + } else { (void)fprintf(stderr, "Assertion failed: (%s), function %s, file %s, line %d.\n", failedexpr, func, file, line); + if (!__crashreporter_info__) { + asprintf(&str, + "Assertion failed: (%s), function %s, file %s, line %d.\n", + failedexpr, func, file, line); + __crashreporter_info__ = str ? str : badasprintf; + } + } abort(); /* NOTREACHED */ }