mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
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:
committed by
Andreas Kling
parent
dacd6b4530
commit
24afab20cc
Notes:
github-actions[bot]
2026-01-13 20:08:32 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/24afab20ccd Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7447 Reviewed-by: https://github.com/R-Goc Reviewed-by: https://github.com/nico Reviewed-by: https://github.com/shannonbooth
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user