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

InspectorServer: Defer removal of InspectableProcess from table

This prevents a crash when the inspected process closes the socket (i.e.
when the app is exited). This crash was caused by the InspectableProcess
removing itself from the global process table within a callback Function
that is stored as part of the InspectableProcess.
This commit is contained in:
sin-ack 2022-04-06 11:00:36 +00:00 committed by Andreas Kling
parent 600596fbae
commit 359365a06a

View file

@ -6,6 +6,7 @@
#include "InspectableProcess.h"
#include <AK/JsonObject.h>
#include <LibCore/EventLoop.h>
namespace InspectorServer {
@ -27,7 +28,7 @@ InspectableProcess::InspectableProcess(pid_t pid, NonnullOwnPtr<Core::Stream::Lo
char c;
[[maybe_unused]] auto buffer = m_socket->read({ &c, 1 });
if (m_socket->is_eof()) {
g_processes.remove(m_pid);
Core::deferred_invoke([pid = this->m_pid] { g_processes.remove(pid); });
return;
}
};