Flush all the streams if CHECK() fails.

It's usually more helpful to see all the output so far.

If we're worried about fflush() failing because of the state we're in, we shouldn't be using stdio at all!

If this _does_ become a problem, we should probably switch to using the internal functions: `__assert2` for bionic, `__assert_fail` for musl/glibc, and `__assert_rtn` for macOS.

Unfortunately although `__assert2` and `__assert_fail` take the same arguments, they're in a different order, so we can't simply add a symbol alias to make that difference go away, and it's not clear that there's enough value to adding an otherwise unused symbol.

Change-Id: I653183737ab6368890bbd9d0e2f37fc5cb2e1dec
This commit is contained in:
Elliott Hughes 2024-03-15 15:23:12 +00:00
parent 3abc30d6a6
commit dc0510ec17

View file

@ -26,7 +26,7 @@
static inline void check_failure(const char* file, int line, const char* function,
const char* failed_expression) {
fprintf(stderr, "%s:%d: %s: assertion \"%s\" failed\n", file, line, function, failed_expression);
fflush(stderr);
fflush(NULL);
abort();
}