From 18d2a74e625ee00ddc506d493498160d15a886c3 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 10 Sep 2021 21:43:19 +0300 Subject: [PATCH] AK: Only try and get the Processor::current_id when it was initialized This caused a null pointer dereference on early boot, since the gs_base was not set yet. --- AK/Format.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/AK/Format.cpp b/AK/Format.cpp index 03d9fab42e1..36b2809e821 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -787,11 +787,15 @@ void vdbgln(StringView fmtstr, TypeErasedFormatParams& params) #ifdef __serenity__ # ifdef KERNEL - if (Kernel::Processor::is_initialized() && Kernel::Thread::current()) { - auto& thread = *Kernel::Thread::current(); - builder.appendff("\033[34;1m[#{} {}({}:{})]\033[0m: ", Kernel::Processor::current_id(), thread.process().name(), thread.pid().value(), thread.tid().value()); + if (Kernel::Processor::is_initialized()) { + if (Kernel::Thread::current()) { + auto& thread = *Kernel::Thread::current(); + builder.appendff("\033[34;1m[#{} {}({}:{})]\033[0m: ", Kernel::Processor::current_id(), thread.process().name(), thread.pid().value(), thread.tid().value()); + } else { + builder.appendff("\033[34;1m[#{} Kernel]\033[0m: ", Kernel::Processor::current_id()); + } } else { - builder.appendff("\033[34;1m[#{} Kernel]\033[0m: ", Kernel::Processor::current_id()); + builder.appendff("\033[34;1m[Kernel]\033[0m: "); } # else static TriState got_process_name = TriState::Unknown;