1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

LibC: Don't format strings when asserting with an unstable heap

If we hit an assertion while the heap isn't in a stable state, we can't
rely on dynamic memory allocation because the malloc mutex is already
held and the heap is most likely corrupted. Instead, we need to bail
out fast before we make the situation even worse.
This commit is contained in:
Jean-Baptiste Boric 2021-09-17 18:13:50 +02:00 committed by Brian Gianforcaro
parent e215580147
commit 8043fcd466
3 changed files with 13 additions and 4 deletions

View file

@ -19,9 +19,11 @@ extern bool __stdio_is_initialized;
#ifndef NDEBUG
void __assertion_failed(const char* msg)
{
dbgln("ASSERTION FAILED: {}", msg);
if (__stdio_is_initialized)
warnln("ASSERTION FAILED: {}", msg);
if (__heap_is_stable) {
dbgln("ASSERTION FAILED: {}", msg);
if (__stdio_is_initialized)
warnln("ASSERTION FAILED: {}", msg);
}
Syscall::SC_set_coredump_metadata_params params {
{ "assertion", strlen("assertion") },