Repository navigation
socket: the vsock descriptor is duplicated before Go takes it - #16
Open
closer-claudio wants to merge 1 commit into
Open
closer-claudio wants to merge 1 commit into
closer-claudio wants to merge 1 commit into
Conversation
VZVirtioSocketConnection owns its file descriptor and closes it when the
object is destroyed (VZVirtioSocketConnection.h). The flat conversion
handed Go that very descriptor; Go made its net.FileConn copy and closed
the original, and the framework's later close hit whatever number the
kernel had reused in between. In zerogravity that was the guest agent's
HTTP connection: a request cut tens of seconds after the vsock dial, seen
twice ("restarting sshd: context canceled", "scutil --set HostName:
context canceled"), each time on a command the guest ran under the
request context. The conversion now hands Go dup() of the descriptor, or
-1 with errno, which Go turns into an error; Go's close is of its own
copy and the framework's is of its own. Upstream fixed the same defect
after our fork point (SocketConnectionDuplicatedFileDescriptor).
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: closer-claudio <[email protected]>
closer-claudio
enabled auto-merge
October 23, 2026 04:24
Contributor
Author
|
Reviewed at 43d5bad |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
convertVZVirtioSocketConnection2Flathands Go adup()of theVZVirtioSocketConnection's file descriptor instead of the descriptor itself, or -1 witherrno, whichnewVirtioSocketConnectionturns into an error. Go's close is now of its own copy; the framework's is of its own. FORK.md records the change.Why
VZVirtioSocketConnectionowns its file descriptor and closes it when the object is destroyed (VZVirtioSocketConnection.hin the 27.0 SDK: "The file descriptor is owned by the VZVirtioSocketConnection. It is automatically closed when the object is destroyed"). The conversion handed Go that very descriptor; Go made itsnet.FileConncopy and closed the original, so the number was freed and reused, and the framework's later close hit whatever had it. In zerogravity that was the guest agent's HTTP connection: a request cut tens of seconds after the vsock dial, seen twice, each time on a command the guest ran under the request context (restarting sshd: context canceled,scutil --set HostName: context canceled). Upstream fixed the same defect after this fork's point (SocketConnectionDuplicatedFileDescriptoron Code-Hex/vz main). A descriptor of -1, which the header defines as a closed connection, now surfaces as an error (dup(-1)fails with EBADF) instead of anos.Fileon a bad number.Both entry points, the dial completion and the listener's accept, go through the one conversion.
Evidence
just lintandjust testgreen. The running-guest evidence is zerogravity's next install on the bumped pin.Created by @apostasie personal assistant