6 minor findings · 10 suggestions
Findings
[minor] · Non-atomic error-socket creation can block SpawnProcess
A concurrent notify launch that inherits the new error socket can keep an IPC-enabled echoipc call blocked until the unrelated process closes it.
Location: src/ipc/libmultiprocess/src/mp/util.cpp:355 (head).
Details and suggested fix
SocketPair() creates descriptors without close-on-exec and sets FD_CLOEXEC in later fcntl calls. If another thread forks in that interval and execs without closing unrelated descriptors, its copy of error_fds[0] remains open. Changing the parent's flags does not change that inherited copy. The new ReadSpawnResult wait cannot receive EOF after the intended child execs until every inherited copy closes. Core permits this overlap between the hidden, trusted echoipc RPC and a configured post-initialization -blocknotify launch through system() when IPC and HAVE_SYSTEM are available; production occurrence is unconfirmed. The base already exposed IPC descriptor inheritance, but had no synchronous error-channel wait. Create socket pairs with SOCK_CLOEXEC where supported, preserving the child-side clearing for the IPC endpoint. Retain and document the non-atomic fallback only on platforms without that flag, such as macOS. This correction belongs upstream in libmultiprocess.
[minor] · The first socket pair leaks if allocating the error pair fails
If the new second SocketPair() allocation fails, SpawnProcess loses both descriptors from the first pair and leaves them open until process exit.
Location: src/ipc/libmultiprocess/src/mp/util.cpp:257 (head).
Details and suggested fix
With only two or three descriptor slots available, the first SocketPair() can succeed and the second can throw with EMFILE. The first result is a plain array of integers, and all explicit cleanup starts at or after fork(), so unwinding closes neither endpoint. ProcessImpl::spawn forwards the call and cannot recover descriptors it never receives. The base allocated only one pair; pre-fork callback or argument-allocation exceptions also now leak four descriptors instead of two. Core currently reaches this through the hidden, trusted echoipc RPC, and production impact under descriptor pressure is unconfirmed. Give each endpoint scoped ownership immediately after creation, including inside SocketPair, and release it only at handoff. Preserve the async-signal-safe child path, which execs or calls _exit without running destructors. A descriptor-limited subprocess test can force the second allocation to fail and verify that the descriptor count stays unchanged.
[minor] · Malformed -ipcchild values now pass descriptor parsing
The v14 parser accepts numeric prefixes, leading whitespace and a leading plus in local -ipcchild values that Core previously rejected.
Location: src/ipc/libmultiprocess/src/mp/util.cpp:345 (head).
Details and suggested fix
Raising MP_MAJOR_VERSION to 14 disables the ToIntegral<SocketId> compatibility implementation, so checkSpawned now calls upstream StartSpawned. Its unchecked std::stoi accepts "3abc", " 3" and "+3" as descriptor 3, and "0x10" as descriptor 0. Instead of returning the existing invalid-value error, parsing can hand an unintended descriptor to makeStream. The parent always uses std::to_string(fd), and no current producer of malformed values was found. Restore the strict parse upstream with std::from_chars, checking both its error and that the end pointer reaches the end of the string. Add a numeric-prefix case such as "3abc" to check_spawned_test.
[minor] · Nonowning ConnectStream leaks its Connection when construct() throws
With destroy_connection=false, a throwing construct() leaves an unreachable Connection holding an event-loop reference and can prevent loop shutdown.
Location: src/ipc/libmultiprocess/include/mp/proxy-io.h:879 (head).
Details and suggested fix
ConnectStream releases its unique_ptr<Connection> before constructing the proxy. If construct() throws, ProxyClientBase runs its cleanup, but that cleanup deletes the connection only when destroy_connection is true. No client is returned from which the caller could recover the pointer, and nonowning mode installs no disconnect deleter. The connection, stream and EventLoopRef therefore remain allocated, preventing done() from becoming true. The only current nonowning caller is the subtree's FooInterface fixture, which has no construct() method; no current caller triggers this combination. In nonowning mode, retain temporary ownership until proxy construction succeeds and destroy the connection on the event-loop thread if construction throws. Extend the disconnected-FooInit test to cover this option and verify loop shutdown.
[minor] · The TSan regression test can finish before its disconnect
If the main test thread is delayed beyond 200 ms, callMessageAsync can succeed and fail the new test's required disconnect assertion.
Location: src/ipc/libmultiprocess/test/mp/test/test.cpp:441 (head).
Details and suggested fix
The method signals fn_called before result building, and the result-building hook only sleeps for 200 ms. The main thread initiates client_disconnect() after waking from that signal. If it is descheduled long enough, the worker can finish serialization and the shared event loop can deliver a successful response before disconnect starts. EXPECT_EXCEPTION then fails despite correct production behavior, and the intended overlap is missed. Keep the worker in the hook until disconnect processing has occurred, using bounded coordination without a happens-before edge, such as polling a relaxed atomic set from testing_hook_disconnected. The access under test precedes the hook, so this can prevent an early response without synchronizing away the race.
[minor] · Local dependency configurations share one Cap'n Proto checkout
Sequential local olddeps and newdeps runs reuse the first Cap'n Proto checkout and compiler cache rather than isolating their requested dependencies.
Location: src/ipc/libmultiprocess/ci/scripts/ci.sh:28 (head).
Details and suggested fix
The clone command consults CAPNP_CHECKOUT only when capnp/ does not exist. Both configurations then build from capnp/build and install into $PWD/capnp-install, without checking out or verifying the requested revision. Running olddeps first leaves newdeps using v0.9.2; reversing the order prevents olddeps from testing its minimum version. The shared CMake cache also retains the first compiler selection. CI_CLEAN=1 does not help because these directories sit outside CI_DIR. Fresh, isolated GitHub Actions matrix jobs are unaffected. Put the dependency source, build and install directories under the configuration-specific CI_DIR so the configurations stay separate and cleanup removes their dependency state.
Optional improvements
[suggestion] · The broad C++23 warning suppression is not a fallback
Compilers accepting both flags receive both suppressions, disabling unrelated C++23-extension diagnostics through Core's shared warning interface.
Location: CMakeLists.txt:527 (head).
Details and suggested fix
These two probes run independently, so newer Clang versions receive -Wno-c++23-extensions even when -Wno-c++23-lambda-attributes handles the libmultiprocess lambda. Because warn_interface feeds core_interface, the broader option suppresses other C++23 extensions in Core's C++20 targets, including clang-cl targets, rather than only this lambda diagnostic. Capture the narrow probe's RESULT_VAR and probe or add the broad suppression only when the narrow probe fails. That preserves the older-Clang workaround without reducing diagnostic coverage on compilers that support the specific warning group.
[suggestion] · Unexpected shutdownWrite errors bypass mandatory connection cleanup
A non-ignored shutdownWrite() exception can skip client-pointer invalidation during destruction; this remains a latent concern with no reachable failure established for currently used valid sockets.
Location: src/ipc/libmultiprocess/src/mp/proxy.cpp:157 (head).
Details and suggested fix
~Connection now rethrows shutdownWrite() failures other than DISCONNECTED and UNIMPLEMENTED before running m_sync_cleanup_fns. Those callbacks release client capabilities and clear ProxyClient::m_context.connection. If deletion propagates the exception, member destruction and deallocation can leave surviving clients with dangling pointers; destruction through a noexcept context such as unique_ptr::reset can terminate instead. Keep the required shutdownWrite() call, but log unexpected errors and complete teardown rather than rethrowing from the destructor. This preserves the pending-data behavior without allowing error reporting to bypass mandatory cleanup.
[suggestion] · Core's dependency table still lists the old Cap'n Proto minimum
Bundled IPC now needs at least Cap'n Proto 0.9.2, or 1.0 with Clang 16+ in C++20, but doc/dependencies.md still lists 0.7.1.
Location: src/ipc/libmultiprocess/CMakeLists.txt:16 (head).
Details and suggested fix
find_package now requires Cap'n Proto 0.9, and the CVE check rejects 0.9.0 and 0.9.1, making 0.9.2 the lowest accepted bundled-subtree version. The Clang 16+/C++20 check additionally rejects the 0.9.x and 0.10.x series. Users following Core's dependency table with bundled IPC enabled can therefore install a listed version and fail configuration. Update the Cap'n Proto row and its PR reference, including the Clang qualification. If older external libmultiprocess builds remain supported with older Cap'n Proto, distinguish that configuration explicitly.
[suggestion] · BuildList's unused category branch promises too much about lvalues
Every in-tree adapter takes the lvalue branch, but unique_ptr interface elements still transfer ownership through it, contrary to the new comment.
Location: src/ipc/libmultiprocess/include/mp/proxy-types.h:307 (head).
Details and suggested fix
The vector, set, unordered-set and map adapters all pass their named value parameter to BuildList without forwarding. Even an originally rvalue container therefore reaches this function as an lvalue, leaving the std::move(*it) branch uninstantiated in those paths. Passing an element as an lvalue also does not prevent consumption: the interface serializer calls unique_ptr::release() regardless of value category. That transfer is required for returned interface lists such as listBars, not an established failure of an existing caller-owned container. Drop the conditional and pass *it directly, preserving mutable interface transfer and vector<bool> prvalue proxies. Reword the comment to describe those behaviors rather than promise non-consuming lvalue serialization.
[suggestion] · The deadlock test's watchdog starts after the blocking spawn call
If the callback regresses into a child forked with target_mutex held, SpawnProcess blocks before the test can reach its 30-second timeout.
Location: src/ipc/libmultiprocess/test/mp/test/spawn_tests.cpp:98 (head).
Details and suggested fix
SpawnProcess now waits in ReadSpawnResult until the child execs or reports an error. In the regression this test targets, the child blocks on its inherited locked mutex and never reaches either event. The releaser thread unlocks only the parent's copy, so the call never returns a pid and the subsequent timeout and kill/reap recovery are unreachable. The mptest registration adds no per-test timeout, leaving recovery to an external or default CTest deadline. Run the mutex-held-at-fork scenario in an isolated helper supervised by a deadline covering the entire spawn operation. On timeout, terminate its process group and reap the helper.
[suggestion] · The before-accept test also passes through the after-accept path
The new listener test can pass without exercising a client closed before accept().
Location: src/ipc/libmultiprocess/test/mp/test/listen_tests.cpp:245 (head).
Details and suggested fix
The server event loop is already running when MakeConnectedSocket() and close() execute on the test thread. It can accept the connection between those calls, then report one disconnect, satisfying the same final assertion as the intended ordering. A passing run therefore does not establish coverage of accepting an already-closed peer. Perform both calls inside a (**server.m_loop_ref).sync(...) callback so the event-loop thread cannot accept until after close. Keep the existing macOS accept-error allowance and disconnect-count expectations.
[suggestion] · The no-calls disconnect test never checks connection deletion
The warning-only assertion would still pass if disconnect stopped deleting the Connection and left cleanup until proxy destruction.
Location: src/ipc/libmultiprocess/test/mp/test/connect_tests.cpp:154 (head).
Details and suggested fix
The disconnect callback logs unexpected network disconnect before delete connection. Removing the deletion would still wake this test, and the default owning cleanup would delete the connection when foo goes out of scope. Loop shutdown therefore does not supply the missing assertion. After the warning, release the test mutex and call setup.m_loop->sync([&] { KJ_EXPECT(!foo->m_context.connection); }); while foo remains alive. This waits for the callback to finish and verifies that ~Connection ran the synchronous cleanup that clears the pointer.
[suggestion] · The exec-failure test does not verify child reaping
Removing KillAndReapChild would leave the new exec-failure assertions passing even though SpawnProcess abandoned an unreaped child.
Location: src/ipc/libmultiprocess/test/mp/test/spawn_tests.cpp:122 (head).
Details and suggested fix
The test checks only ENOENT and execvp in the exception. The error path would throw the same exception without KillAndReapChild, leaving the child to become a zombie. Because failure returns no pid, the test cannot inspect it directly. Run the failure case in an isolated forked helper and, after catching the expected exception, require waitpid(-1, nullptr, WNOHANG) to fail with ECHILD. Isolation keeps unrelated harness children out of that check.
[suggestion] · The new time_point codec has no serialization test
No test exercises the new time_point overloads or verifies that they preserve signed, sub-second tick counts.
Location: src/ipc/libmultiprocess/include/mp/type-chrono.h:38 (head).
Details and suggested fix
The codec writes time_since_epoch().count() and reconstructs a value with Duration{input.get()}, but the subtree fixture neither includes type-chrono.h nor exposes a time_point field. Core includes the header without adding a time-point IPC field that exercises these overloads. Returning the epoch, truncating sub-second ticks or treating ticks as seconds could therefore go unnoticed. Add a millisecond time_point fixture backed by Int64, round-trip a negative non-whole-second value such as -123 ticks and a value beyond the 32-bit range, and assert a raw wire value so reciprocal unit mistakes cannot cancel out.
[suggestion] · Fixed-array length rejection has no regression coverage
No test exercises the new exact-size guard before copying a Data field into an unsigned char[N] destination.
Location: src/ipc/libmultiprocess/include/mp/type-char.h:34 (head).
Details and suggested fix
The reader now copies the entire input range rather than a fixed number of bytes, making the new length check essential. Without it, short input would partially update the destination and oversized input would overrun it. Neither the test fixture nor Core includes type-char.h, so existing dynamic-data tests do not protect this overload. Add a direct adapter test with a four-byte destination initialized to sentinel bytes. Require three- and five-byte inputs to throw without changing it, and verify that a four-byte input copies exactly.