ladybird/Libraries/LibIPC
Rocco Corsi b6b56910e8 LibIPC: Shutdown IPC handler when transport is lost during sync event
If the Ladybird process crashes or just ends normally, the IPC transport
connection with WebContent may be shutdown after a send sync event (for
example: WebContentClient DidRequestCookie) was sent from WebContent,
but before the Ladybird process provided the matching sync event
response (for example: WebContentClient DidRequestCookieResponse). This
can lead to a runaway WebContent process if other IPC events (for
example: WebContentServer DidPaint, or SetSystemVisibilityState, or
MouseEvent, or CloseServer, etc...) are also queued when the IPC
connection is shutdown.

At the core of the issue is that the loop waiting for the matching
send sync response will prioritize waiting for the response and remain
spinning even if the IPC connection is reporting that it was shutdown,
but only if there happens to be other unrelated events received before
the IPC shutdown is detected. These unrelated events will not be
processed because the loop is stuck waiting for the response that due
to the Ladybird process having stopped, will never be sent.

Because the shutdown of the IPC connection is not handled when other
events happen to be also present, new events may be posted for transfer
by the WebContent process if the page is very active. If many new events
are posted this could lead to a slow or very quick memory leak in the
WebContent process due to the queue growing large, sometimes all the way
to total system memory exhaustion. If no events or only a few new events
are sent, then the leak may be hard to detect.

This PR fixes the faulty IPC shutdown handling by not getting stuck if
any messages are present in the receive queue. Before returning to the
caller any remaining messages will be immediately processed.
2025-10-07 17:04:32 -05:00
..
AutoCloseFileDescriptor.h LibIPC: Move AutoCloseFileDescriptor to its own header 2025-06-17 15:36:47 -06:00
CMakeLists.txt CMake: Rename serenity_* helper functions/macros to ladybird_* 2025-07-03 23:19:41 +02:00
Concepts.h LibIPC: Add a generic encoder for spans 2025-03-09 11:14:20 -04:00
Connection.cpp LibIPC: Shutdown IPC handler when transport is lost during sync event 2025-10-07 17:04:32 -05:00
Connection.h LibIPC: Delete unused code in Connection 2025-10-01 14:59:23 -04:00
ConnectionFromClient.h Everywhere: Make TransportSocket non-movable 2025-04-09 15:27:52 +02:00
ConnectionToServer.h Everywhere: Make TransportSocket non-movable 2025-04-09 15:27:52 +02:00
Decoder.cpp LibIPC: Remove DateTime encoder/decoder 2025-09-30 12:39:01 +02:00
Decoder.h LibWeb/LibURL/LibIPC: Extend createObjectURL to also accept MediaSources 2025-08-19 23:50:38 +02:00
Encoder.cpp LibIPC: Remove DateTime encoder/decoder 2025-09-30 12:39:01 +02:00
Encoder.h LibWeb/LibURL/LibIPC: Extend createObjectURL to also accept MediaSources 2025-08-19 23:50:38 +02:00
File.cpp LibWeb: Send IPC messages exceeding socket buffer through shared memory 2025-04-03 13:55:41 +02:00
File.h LibCore+LibIPC: Remove badge on File::leak_fd 2025-06-14 16:03:26 -04:00
FileWindows.cpp LibCore: Implement System::set_close_on_exec 2025-03-19 20:25:24 -06:00
Forward.h LibIPC: Add some type aliases and MessageBuffer helpers 2025-07-18 10:09:02 -04:00
HandleType.h LibIPC: Port to Windows 2025-02-12 22:31:43 -07:00
Message.cpp LibIPC: Add some type aliases and MessageBuffer helpers 2025-07-18 10:09:02 -04:00
Message.h LibIPC: Add some type aliases and MessageBuffer helpers 2025-07-18 10:09:02 -04:00
MessageWindows.cpp LibIPC: Add some type aliases and MessageBuffer helpers 2025-07-18 10:09:02 -04:00
MultiServer.h Everywhere: Make TransportSocket non-movable 2025-04-09 15:27:52 +02:00
SingleServer.h Everywhere: Make TransportSocket non-movable 2025-04-09 15:27:52 +02:00
Stub.h Meta: Enforce newlines around namespaces 2025-05-14 02:01:59 -06:00
Transport.h LibIPC: Port to Windows 2025-02-12 22:31:43 -07:00
TransportSocket.cpp Everywhere: Use a forward declaration for pointers to Threading::Thread 2025-09-22 17:28:21 -05:00
TransportSocket.h Everywhere: Use a forward declaration for pointers to Threading::Thread 2025-09-22 17:28:21 -05:00
TransportSocketWindows.cpp LibWeb: Enable in Windows CI 2025-06-30 10:50:36 -06:00
TransportSocketWindows.h LibWeb: Enable in Windows CI 2025-06-30 10:50:36 -06:00