Repository navigation
Document SelectError results for out-of-band data on Linux and Apple platforms - #13301
Open
caraioniurie47 wants to merge 1 commit into
Open
caraioniurie47 wants to merge 1 commit into
caraioniurie47 wants to merge 1 commit into
Conversation
On Linux, Socket.Poll(SelectError) returns true, and Socket.Select keeps the socket in checkError, when the socket has OutOfBandInline set and out-of-band data hasn't been read yet, as POSIX defines. On macOS, iOS, tvOS and Mac Catalyst, Poll(SelectError) doesn't report out-of-band data, because XNU's poll() sets POLLPRI only with POLLHUP. Say so in the Poll return values and the Select remarks. Fixes dotnet/runtime#135995 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
On Linux and on macOS, iOS, tvOS and Mac Catalyst,
Socket.Poll(..., SelectMode.SelectError)doesn't follow its docs for out-of-band data. The docs saySelectErrorreturnstrue"if OutOfBandInline is not set and out-of-band data is available", which is what Windows does, and theSelectdocs don't mention out-of-band data. Reviewing a fix for Apple platforms, dotnet/runtime#135996, an area owner suggested: "I would probably document it as platform limitation."Linux
With
OutOfBandInlineset and an out-of-band byte not read yet,Poll(SelectError)returnstrueandSocket.Selectkeeps the socket incheckError. A loopback TCP pair,OutOfBandInlineset on the receiver, one byte sent withSocketFlags.OutOfBand:Poll(0, SelectError)TrueFalseSelectcheckErrorcountLinux follows POSIX, whose
pselectpage says: "A socket shall also be considered to have an exceptional condition pending if an out-of-band data mark is present in the receive queue."tcp_pollsetsEPOLLPRIwhateverSO_OOBINLINEsays:tcp.c:623-624Apple platforms
Poll(SelectError)doesn't report out-of-band data: it waits out the timeout and returnsfalse. XNU's socket filter never returnsEV_OOBAND, sopoll()setsPOLLPRIonly along withPOLLHUP:sys_generic.c:1867-1875dotnet/runtime#135995 has the rest of the XNU analysis and the upstream CI failures on macOS 15 x64 and macOS 26 arm64 that showed it.
The change
Both
Polloverloads'SelectErroritem gains a sentence for Linux and one for Apple platforms. The remarks ofSelect(IList, IList, IList, int)gain two sentences on out-of-band data after the one on failed connects. The Linux sentences say "on some platforms, such as Linux" because Linux is the only Unix platform where it ran.Options not taken:
select()forPoll(SelectError): Report out-of-band data from Socket.Poll(SelectError) on Apple platforms runtime#135996, declined above.NOTE_OOB: a new native export and a kqueue descriptor per call.SO_OOBINLINEset out of the result: against POSIX, and code may use the report to learn that urgent data is pending.Pollonly: the same costs, andPollandSelectwould then disagree.Fixes dotnet/runtime#135995
Note
AI-generated, written at my direction and reviewed by me before posting.
The Linux result ran on Ubuntu 24.04.5 LTS (kernel 6.18.44, x64) with .NET 8.0.32 and 11.0.0-rc.1.26420.103, the Windows one on Windows 11 with .NET 8.0.32 and 10.0.13. Nothing was run on Apple platforms: upstream CI on macOS ran the
OutOfBandInline-off case (dotnet/runtime#135995); the rest is from the XNU xnu-12377.1.9 source.Internal previews
Build report