Skip to content

Fix build break - #136388

Merged
lewing merged 1 commit into
dotnet:mainfrom
jkotas:fix-bb
Oct 23, 2026
Merged

lewing merged 1 commit into
dotnet:mainfrom
jkotas:fix-bb

Conversation

@jkotas

@jkotas jkotas commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Conflict between #136263 and earlier PR

@jkotas
jkotas marked this pull request as ready for review October 23, 2026 22:11
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 23, 2026
@jkotas
jkotas requested a review from EgorBo October 23, 2026 22:11
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jkotas
jkotas requested a review from steveisok October 23, 2026 22:12
@EgorBo

EgorBo commented Oct 23, 2026

Copy link
Copy Markdown
Member

Oops, sorry, I had it in mind, but forgot when I merged the 2nd PR 😞

@EgorBo

EgorBo commented Oct 23, 2026

Copy link
Copy Markdown
Member

I think it should be safe to merge it as is to unblock others

@EgorBo
EgorBo enabled auto-merge (squash) October 23, 2026 22:38
@lewing

lewing commented Oct 23, 2026

Copy link
Copy Markdown
Member

/ba-g fast merge build break

@lewing
lewing disabled auto-merge October 23, 2026 22:39
@lewing
lewing merged commit 16de7cf into dotnet:main Oct 23, 2026
36 of 129 checks passed
@jkotas
jkotas deleted the fix-bb branch October 23, 2026 22:56
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 26, 2026
lewing added a commit that referenced this pull request Oct 26, 2026
On Unix, a zero-byte receive is implemented as a 1-byte `MSG_PEEK`.
wasi-libc rejects `MSG_PEEK` with `EOPNOTSUPP`, so every zero-byte
receive fails on WASI. Callers such as HTTP/2 in `SocketsHttpHandler`
rely on zero-byte reads to wait for data.

This was split out of #136234 at a reviewer's request.

## Fix

On WASI, a zero-byte receive with no flags now does this instead:

- It polls the socket for `POLLIN` with a zero timeout, and completes
only when the socket is readable.
- If the socket can't be polled, it does a zero-length `recv` so the
real error is reported. For example, wasi-libc returns `EOPNOTSUPP` for
an unconnected TCP socket, and the `recv` reports `ENOTCONN` instead.
- WASI poll events don't say which direction is ready, so queued
zero-byte receives re-run this check. They no longer complete on any
event.

Non-WASI behavior is unchanged.

Not covered: a zero-byte `ReceiveFrom`/`ReceiveMessageFrom` that passes
an endpoint still takes the `MSG_PEEK` path on WASI.

## Known caveat

After data has been drained, one zero-byte receive can complete early,
because wasmtime keeps readiness set until a read would block. wasmtime
treats this as by design (bytecodealliance/wasmtime#9667). The next real
read then waits correctly.

## Validation

- **CoreCLR WASI, Release, wasmtime 49.0.1:** the full
System.Net.Sockets functional tests ran 653 tests: 565 passed, 0 failed,
88 skipped. The baseline on main is about 645 run with 0 failed. The two
new tests passed in all 4 variants that run on WASI.
- **macOS, Release:** I ran the `SendReceive_*` classes (Sync,
SyncForceNonBlocking, Apm, Task, Eap, SpanSync, MemoryArrayTask,
MemoryNativeTask). Total was 252 with 0 failed, and both new tests
passed in every variant.
- `Receive0Byte_NotConnected_Throws` runs on all platforms.
`Receive0Byte_Udp_CompletesWhenDatagramArrives` runs on Unix only,
because on Windows a zero-byte receive consumes the datagram.
- `SocketsHttpHandler`/HTTP/2 isn't enabled on WASI in main, so the
motivating HTTP/2 scenario is covered in #136234 rather than here.
- Building main locally needed the `fgopt.cpp` fix from #136388. That
fix is not part of this PR.

Related: #107981

> [!NOTE]
> This PR was generated with GitHub Copilot.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants