You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Two session launches racing for a stale socket can both claim it #18962
claimLocalStream() (src/cpp/core/include/core/http/LocalStreamSocketUtils.hpp, added in #18944) binds first. If the bind fails with EADDRINUSE, it checks whether anything is listening on the path with a non-blocking connect(), and if nothing answers, it removes the path and binds again. Two processes claiming the same stale path at the same time can both get past that check:
A and B both fail to bind with EADDRINUSE, and both find nothing listening.
B removes the stale socket, binds, and listens.
A's removeIfExists() unlinks B's new socket, and A binds.
B keeps running, listening on an unlinked socket, which is the state that locked the user out in #18941. B also reads its socket's identity with lstat() on the path after binding, so if A rebinds between B's bind and B's lstat(), B records A's identity and removes A's socket when it exits.
The comment "a process that bound the path since our probe keeps it" covers a bind that lands between A's remove and A's rebind, but not one between A's probe and A's remove.
Likelihood
This needs a stale socket (left by a session that died without cleaning up) and two launches of the same session reaching the claim within microseconds of each other. #18944 closed the much wider window (seconds) behind #18941, so this is hardening rather than an observed failure.
Possible fix
Serialize the check, remove, and rebind with an exclusive flock() on a lock file next to the socket (e.g. <stream>.lock), held only for the duration of the claim. Once the claim is serialized, reading the identity from the path with lstat() is safe as well.
Activity