From c5a0bc4d6f4e737be7763adb032188bfece17e2f Mon Sep 17 00:00:00 2001 From: Darko Lulic Date: Fri, 7 Aug 2026 12:02:40 +0000 Subject: [PATCH] Fix readPIDFromPeer crash when child dies during launch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a child process (WPEWebProcess) is killed before sending its PID — e.g. by SIGTERM during container teardown — recvmsg() returns 0 (EOF). Previously this fell through to g_error("Unexpected short read") which called abort(), crashing the parent. readPIDFromPeer now returns 0 on EOF. When it returns 0, the launch callback calls didFinishLaunchingProcess(0, IPC::Connection::Identifier{}), which flows into WebProcessProxy::processDidTerminateOrFailedToLaunch( ProcessTerminationReason::Crash) — the same crash notification path that fires when a running WebProcess dies. Pages get notified, crash handling kicks in, no abort. The socket monitor is then removed cleanly. --- Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp | 5 +++++ .../UIProcess/Launcher/glib/ProcessLauncherGLib.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp index 87969d7f027e1..43091cc588639 100644 --- a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp +++ b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp @@ -647,6 +647,11 @@ pid_t readPIDFromPeer(int socket) if (ret == -1) g_error("readPIDFromPeer: Failed to read pid from PID socket: %s", g_strerror(errno)); + if (ret == 0) { + // Peer died before sending PID (e.g. SIGTERM during container teardown). + return 0; + } + if (message.msg_controllen <= 0) g_error("readPIDFromPeer: Unexpected short read from PID socket"); diff --git a/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp b/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp index 271987adce84e..0e44b67f2f04b 100644 --- a/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp +++ b/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp @@ -258,7 +258,13 @@ void ProcessLauncher::launchProcess() g_error("Failed to read pid from child process"); m_processID = IPC::readPIDFromPeer(g_socket_get_fd(pidSocket.get())); - RELEASE_ASSERT(m_processID); + if (!m_processID) { + m_socketMonitor.stop(); + close(m_pidServerSocket); + m_pidServerSocket = -1; + didFinishLaunchingProcess(0, IPC::Connection::Identifier { }); + return G_SOURCE_REMOVE; + } m_socketMonitor.stop();