Repository navigation
fix: don't kill the primary instance on large second-instance messages - #52628
Conversation
jkleinsc
left a comment
There was a problem hiding this comment.
Overall LGTM other than we should document the new limit in our docs.
Some additional feedback from AI review:
Non-blocking socket relies on a DCHECK (pre-existing, but worth fixing here): Upstream makes the accepted fd non-blocking via DCHECK(base::SetNonBlocking(connection_socket)), which doesn't execute when DCHECKs are compiled out — so in release builds the fd stays blocking. This hazard predates this PR (the old ReadFromSocketWithTimeout loop could also block on a stalled client), but the new read loop depends on EAGAIN for its "wait for the rest of the message" path, which never triggers on a blocking fd — instead the IO thread sits in read() until EOF, and the cleanup timer_ (same thread) can't fire. Suggest adding a hunk to set non-blocking unconditionally, e.g. if (!base::SetNonBlocking(connection_socket)) PLOG(ERROR) << ....
Oversized messages are silently swallowed: >32 MiB gets drained, ACK'd, and dropped — second-instance never fires and the second instance exits as if handled, with only a LOG(ERROR). Reasonable fallback, but docs/api/app.md (requestSingleInstanceLock / additionalData) should mention the 32 MiB cap and drop behavior.
Write timeout is per-blocked-write, not overall: with SO_SNDTIMEO also set to timeout, a hung primary costs ~2× timeout before giving up, and a slow-but-alive reader can extend the total well past timeout. Probably intended — a comment clarifying the bound is per-block would help.
Nits: WaitSocketForWrite inherits the select()/FD_SETSIZE UB pattern from WaitSocketForRead (fine for consistency; poll() would be safer). The 4 KiB chunk means ~8k read() syscalls for a max-size message — 64 KiB would be a free win. Comment grammar: "Wait a socket for write" → "Wait for a socket to become writable".
|
Heads up: Windows CI builds moved to new runners on Monday and the old ones have now been removed. This branch predates that, so its Windows build jobs still point at the old runners and will sit queued forever if CI runs again. Rebasing on |
The POSIX process singleton read a second instance's notification into a fixed 32 KiB buffer and gave up as soon as writing to the socket would block. Command lines or additionalData payloads beyond those limits were either silently truncated or, when the write couldn't complete, made the second instance kill the primary process as unresponsive.
efd445e to
aa05298
Compare
Changes addressed and documentation added
|
Release Notes Persisted
|
|
I was unable to backport this PR to "41-x-y" cleanly; |
|
I was unable to backport this PR to "43-x-y" cleanly; |
|
I was unable to backport this PR to "42-x-y" cleanly; |
|
I have automatically backported this PR to "44-x-y", please check out #52950 |
|
@VerteDinde has manually backported this PR to "43-x-y", please check out #53156 |
|
@VerteDinde has manually backported this PR to "42-x-y", please check out #53157 |
#53157) fix: don't kill the primary instance on large second-instance messages (#52628) The POSIX process singleton read a second instance's notification into a fixed 32 KiB buffer and gave up as soon as writing to the socket would block. Command lines or additionalData payloads beyond those limits were either silently truncated or, when the write couldn't complete, made the second instance kill the primary process as unresponsive. (cherry picked from commit 1652d8e)
#53156) fix: don't kill the primary instance on large second-instance messages (#52628) The POSIX process singleton read a second instance's notification into a fixed 32 KiB buffer and gave up as soon as writing to the socket would block. Command lines or additionalData payloads beyond those limits were either silently truncated or, when the write couldn't complete, made the second instance kill the primary process as unresponsive. (cherry picked from commit 1652d8e)
Description of Change
The POSIX process singleton read a second instance's notification message into a fixed 32 KiB buffer, and the sending side gave up as soon as
write()would block on its non-blocking socket. A command line oradditionalDatapayload beyond those limits was therefore either silently truncated or, when the write couldn't complete, made the second instance SIGKILL the primary process as "unresponsive."This extends the existing
additionalDatapatch so the primary reads the message into a growable buffer until the client shuts down its end of the socket, and the client waits for the socket to become writable instead of bailing out. Adds specs covering a largeadditionalDatapayload and a long command-line argument.Checklist
npm testpassesRelease Notes
Notes: Fixed the primary instance being killed or receiving truncated arguments when a second instance passed a very long command line or large
additionalDatatoapp.requestSingleInstanceLock().