From 73cb56604195b5c1498866908be899a836cbf05a Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 19 May 2021 10:18:06 +0430 Subject: [PATCH] AK: Make vout() log to debug instead of VERIFY()'ing In case the write was to stderr/stdout, and it just so happened to fail because of an issue like "the pty is gone", VERIFY() would end up calling vout() back to write to stderr, which would then fail forever until the stack is exhausted. "Fixes" the issue where the Shell would crash in horrible ways when the terminal is closed. --- AK/Format.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AK/Format.cpp b/AK/Format.cpp index 9ee6a04cda..d93bf20062 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -20,6 +20,7 @@ # include #else # include +# include #endif namespace AK { @@ -608,7 +609,10 @@ void vout(FILE* file, StringView fmtstr, TypeErasedFormatParams params, bool new const auto string = builder.string_view(); const auto retval = ::fwrite(string.characters_without_null_termination(), 1, string.length(), file); - VERIFY(static_cast(retval) == string.length()); + if (static_cast(retval) != string.length()) { + auto error = ferror(file); + dbgln("vout() failed ({} written out of {}), error was {} ({})", retval, string.length(), error, strerror(error)); + } } #endif