diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-09-10 21:43:19 +0300 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2021-09-10 22:58:08 +0300 |
commit | 18d2a74e625ee00ddc506d493498160d15a886c3 (patch) | |
tree | 70a70059ca838e8b7b554bcfd58cfed05ed8e693 /AK | |
parent | bc7b0a8986aa56a02ed2b13b6f70169961506b23 (diff) | |
download | serenity-18d2a74e625ee00ddc506d493498160d15a886c3.zip |
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.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Format.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/AK/Format.cpp b/AK/Format.cpp index 03d9fab42e..36b2809e82 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; |