5 minor findings · 4 suggestions
Earlier concerns neither republished nor resolved: 1 major finding · 2 minor findings · 1 suggestion. See the Run archive for their assessments.
Findings
[minor] · Windows spawn pipe can be claimed by another local user
Another local user can open the predictable pipe before the child and make the spawn fail; the duplicated socket is not exposed, and the only identified caller is the hidden echoipc test RPC.
Location: src/ipc/libmultiprocess/src/mp/util.cpp:419 (head).
Details and suggested fix
SpawnProcess creates a single-instance pipe with a predictable name and the default DACL, which grants read access to Everyone and the anonymous account. A process running as another local user can open it after CreateNamedPipeA and before the child connects. The parent then writes the WSAPROTOCOL_INFO to that client without checking its PID. The child cannot open the busy pipe, exits, and the spawn fails. WSADuplicateSocket targets the child PID, so the other process cannot use the socket. The only identified caller is the hidden echoipc test RPC, though this is the bootstrap path for all spawned Windows processes. Restrict pipe access to the current user, add PIPE_REJECT_REMOTE_CLIENTS and FILE_FLAG_FIRST_PIPE_INSTANCE, and verify GetNamedPipeClientProcessId matches pi.dwProcessId before writing.
[minor] · Windows IPC bind can delete an unrelated empty file
An existing zero-byte file at the operator-configured -ipcbind path is silently removed; no production configuration placing such a file there was identified.
Location: src/ipc/process.cpp:160 (head).
Details and suggested fix
On Windows, ProcessImpl::bind removes an existing path when it is a regular file of size zero, which cannot distinguish an AF_UNIX socket from an ordinary empty file. If bitcoin-node starts with -ipcbind=unix:<path> and that path contains an empty placeholder or marker file, bind deletes it before proceeding. On POSIX, the same configuration leaves the file in place and bind fails with EADDRINUSE. No configuration placing an unrelated empty file at the IPC path was identified, so production impact is unconfirmed. Remove the path only when it can be identified as an AF_UNIX socket, such as by checking for a reparse point tagged IO_REPARSE_TAG_AF_UNIX; otherwise, let bind fail.
[minor] · Failed Windows spawns leak sockets and process handles
Windows spawn failures can leave sockets and, after launch, the process handle open; repeated production failures that would cause accumulation were not identified.
Location: src/ipc/libmultiprocess/src/mp/util.cpp:447 (head).
Details and suggested fix
If a child exits before connecting, the error branch closes event and pipe but leaves both SocketPair() sockets and pi.hProcess open. Earlier failures can also leak resources: CreateProcessA failure leaves the sockets and pipe open, while CreateEvent failure after launch can leave a child waiting on the pipe. Unlike the Unix path, these errors do not close the sockets and kill and reap the child. Repeated failures in a long-running parent would accumulate handles, but no current production scenario producing repeated failures was identified. Use scoped owners for the sockets, pipe, events, and process handle, releasing them only on success; if a step fails after launch, terminate and wait for the child if it is still running.
[minor] · Windows GUI version metadata drops the “Core” product name
Windows GUI binaries now report “Bitcoin” instead of “Bitcoin Core” in ProductName and FileDescription, and the values no longer follow CLIENT_NAME.
Location: cmake/module/AddWindowsResources.cmake:19 (head).
Details and suggested fix
The removed resource file set ProductName to CLIENT_NAME and FileDescription to CLIENT_NAME " (GUI node for Bitcoin)", with CLIENT_NAME set to “Bitcoin Core.” The replacement hard-codes RC_PRODUCT_NAME to “Bitcoin” when ICON_DIR is passed, and the Qt build passes “Bitcoin (GUI node for Bitcoin)” as the description. Consequently, release bitcoin-qt.exe files show those values in Explorer and Task Manager instead of the previous “Bitcoin Core” versions. This affects metadata only. Set RC_PRODUCT_NAME and the GUI descriptions from ${CLIENT_NAME}.
[minor] · Spawn timeout test can write through a dangling reference
If SpawnProcess finishes after the test's 30-second deadline, its detached worker stores to the destroyed stack-local done flag.
Location: src/ipc/libmultiprocess/test/mp/test/spawn_tests.cpp:50 (head).
Details and suggested fix
The worker captures the stack-local std::atomic<bool> done by reference and is detached. When the deadline expires, the test records a failure and returns, destroying done while the worker may still be inside SpawnProcess. If the call later returns or throws, done.store(true) writes to dead stack memory and can corrupt a later test. This affects only the test's timeout path: a run that hangs forever never reaches the store. Hold the flag in a std::shared_ptr<std::atomic<bool>> captured by value.
Optional improvements
[suggestion] · MinGW retains ThreadContext for every completed IPC worker
A long-running MinGW bitcoin-node -ipcbind retains memory for each worker thread it has created, not just live threads; the growth rate was not measured.
Location: src/ipc/libmultiprocess/src/mp/proxy.cpp:67 (head).
Details and suggested fix
Each client that makes a Context call on a new connection triggers ThreadMap.makeThread, and the server worker initializes its ThreadContext through CurrentThread(). When the client disconnects, the worker is joined, but MinGW's trivially destructible thread_local pointer does not delete the context, so its ThreadContext and thread_name string remain allocated. A node serving repeated short-lived clients therefore retains memory proportional to the total number of worker threads created. This now applies to default MinGW builds because IPC is enabled by default for Windows and NO_IPC is empty for mingw32 depends builds. The per-thread allocation is small, but its growth rate was not measured. Explicitly delete the context at the end of the makeThread and makePool thread lambdas, after the wait loop returns and the destructor clears the maps.
[suggestion] · Functional tests remove stale Windows sockets before bind can clean them up
The framework deletes leftover Windows IPC socket files before each start, so functional tests do not exercise the new bind cleanup used for restart after a crash.
Location: test/functional/test_framework/test_node.py:289 (head).
Details and suggested fix
On Windows, TestNode.start unlinks ipc_socket_path before every start because a stale socket file can cause EADDRINUSE. That prevents tests from reaching the new stale-socket cleanup in ProcessImpl::bind. If the heuristic misses socket files on some toolchain, restarting bitcoin-node -ipcbind after a crash could fail with EADDRINUSE while CI passes. The framework comment also conflicts with interface_ipc_cli.py, which says bitcoind removes the socket file on clean Windows shutdown and has a TODO to clarify the behavior. Remove the framework-side unlink or make it opt-in per test, then test restarting a node with a leftover socket file still at the -ipcbind path.
[suggestion] · Build documentation gives outdated IPC defaults for Windows
depends/README.md and doc/multiprocess.md do not reflect that IPC is now enabled by default on Windows.
Location: depends/Makefile:43 (head).
Details and suggested fix
NO_IPC now defaults to empty for mingw32, and ENABLE_IPC defaults to ON on every platform. However, depends/README.md still says NO_IPC is the default on Windows, while doc/multiprocess.md describes IPC as enabled by default on Unix systems. Update both documents to state the Windows default and the Cap'n Proto requirement that comes with it.
[suggestion] · capnp receives a Windows-only define on every depends host
The unconditional _WIN32_WINNT=0x0602 flag affects capnp builds on non-Windows hosts and targets a lower API level than Bitcoin Core on Windows.
Location: depends/packages/capnp.mk:14 (head).
Details and suggested fix
The define is in the unconditional set_vars block, so it is added to capnp builds for every host and changes their package build IDs. On mingw32 it targets Windows 8, while Bitcoin Core compiles with _WIN32_WINNT=0x0A00 and zeromq.mk scopes its Windows setting to mingw32 with that value. Move the define to $(package)_cppflags_mingw32, which funcs.mk supports, and use 0x0A00 or explain why capnp needs 0x0602.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: A live child that never connects can block Windows spawn indefinitely
- [minor]: Unix StartSpawned accepts trailing garbage in the descriptor string
- [minor]: Initialize Winsock before creating a Windows socket pair
- [major]: Drain the pending named-pipe connection before unwinding