fix: lock crash report ring buffer (SMP race) and guard crashpad crash loop

This commit is contained in:
2026-06-19 19:36:21 +02:00
parent 820b908b80
commit de871ac402
5 changed files with 72 additions and 28 deletions
+12
View File
@@ -10,6 +10,7 @@
#include <Memory/Paging.hpp>
#include <Memory/HHDM.hpp>
#include <Libraries/Memory.hpp>
#include <Libraries/String.hpp>
#include <Terminal/Terminal.hpp>
#include <CppLib/Stream.hpp>
#include <CppLib/Spinlock.hpp>
@@ -1399,6 +1400,17 @@ namespace Sched {
// handle to that same out-stream so it can surface a textual crash
// report to the console user when no desktop is running.
Process* crasher = GetProcessByPid(crasherPid);
// Crash-loop guard: never spawn a crashpad to report on the crashpad
// itself. If crashpad.elf faults (startup bug, OOM, etc.) we would
// otherwise spawn another crashpad, which can fault again, ad infinitum
// -- a fork bomb that also exhausts process slots and report buffers.
if (crasher && Lib::strcmp(crasher->name, crashpadPath) == 0) {
Kt::KernelLogStream(Kt::ERROR, "Sched")
<< "crashpad faulted; not spawning a nested crashpad";
return -1;
}
int crasherSlot = Ipc::SlotForPid(crasherPid);
bool inheritRedir = crasher && crasher->redirected &&
crasher->ioOutHandle >= 0 && crasherSlot >= 0;