From 27db7ed11fa53c23ea97929446610dd54b262dec Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 28 Apr 2025 17:56:09 -0600 Subject: [PATCH] LibIPC: Guard better against closure in the TransportSocket send thread And crash less when the socket is closed while there are still messages in the queue. --- Libraries/LibIPC/TransportSocket.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Libraries/LibIPC/TransportSocket.cpp b/Libraries/LibIPC/TransportSocket.cpp index 62136877af2..766a07807d1 100644 --- a/Libraries/LibIPC/TransportSocket.cpp +++ b/Libraries/LibIPC/TransportSocket.cpp @@ -68,8 +68,15 @@ TransportSocket::TransportSocket(NonnullOwnPtr socket) ReadonlyBytes remaining_to_send_bytes = bytes; Threading::RWLockLocker lock(m_socket_rw_lock); + if (!m_socket->is_open()) + break; auto result = send_message(*m_socket, remaining_to_send_bytes, fds); if (result.is_error()) { + if (result.error().is_errno() && result.error().code() == EPIPE) { + // The socket is closed, we can stop sending. + VERIFY(!m_socket->is_open()); + break; + } dbgln("TransportSocket::send_thread: {}", result.error()); VERIFY_NOT_REACHED(); }