LibWebView: Defer process cleanup to avoid signal handler deadlock

When a child process exits, the SIGCHLD handler was destroying the
Process object synchronously within the signal dispatch context. This
triggered Process::~Process() which called m_connection->shutdown(),
attempting to join the IPC IO thread.

Joining threads from within signal handler context can cause deadlocks,
as observed when WebContent crashes during test-web runs.

Fix this by deferring the on_process_exited callback using
Core::deferred_invoke(), ensuring the Process destruction happens in
normal event loop context.
This commit is contained in:
Andreas Kling
2026-01-13 00:14:55 +01:00
committed by Andreas Kling
parent dacd6b4530
commit 24afab20cc
Notes: github-actions[bot] 2026-01-13 20:08:32 +00:00

View File

@@ -57,8 +57,13 @@ ProcessManager::ProcessManager()
while (!result.is_error() && result.value().pid > 0) {
auto& [pid, status] = result.value();
if (WIFEXITED(status) || WIFSIGNALED(status)) {
if (auto process = remove_process(pid); process.has_value())
on_process_exited(process.release_value());
if (auto process = remove_process(pid); process.has_value()) {
// Defer the callback to avoid destroying Process from signal handler context,
// which would try to join the IPC IO thread and potentially deadlock.
Core::deferred_invoke([this, process = process.release_value()]() mutable {
on_process_exited(move(process));
});
}
}
result = Core::System::waitpid(-1, WNOHANG);
}