fix: lock crash report ring buffer (SMP race) and guard crashpad crash loop
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user