1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Kernel: Handle string format error in page_fault_handler(..) :^)

Utilize the new KString::formatted to provide a fallback
if formatting fails because of OOM or whatever reason.
This commit is contained in:
Brian Gianforcaro 2021-11-20 00:45:14 -08:00 committed by Andreas Kling
parent 4cc41ea186
commit a5cec06135

View file

@ -403,7 +403,9 @@ void page_fault_handler(TrapFrame* trap)
if (current_thread) {
auto& current_process = current_thread->process();
if (current_process.is_user_process()) {
(void)current_process.try_set_coredump_property("fault_address"sv, String::formatted("{:p}", fault_address));
auto fault_address_string = KString::formatted("{:p}", fault_address);
auto fault_address_view = fault_address_string.is_error() ? ""sv : fault_address_string.value()->view();
(void)current_process.try_set_coredump_property("fault_address"sv, fault_address_view);
(void)current_process.try_set_coredump_property("fault_type"sv, fault.type() == PageFault::Type::PageNotPresent ? "NotPresent"sv : "ProtectionViolation"sv);
StringView fault_access;
if (fault.is_instruction_fetch())