Fix recvmsg msghdr outputs - #27399
Merged
Merged
Conversation
sbc100
reviewed
Jul 21, 2026
sbc100
approved these changes
Jul 21, 2026
sbc100
enabled auto-merge (squash)
July 21, 2026 22:45
recvmsg was writing iovecs after the first at incorrect offsets, and was not updating msg_namelen, msg_controllen or msg_flags in the caller's struct msghdr.
guybedford
force-pushed
the
recvmsg-msghdr-fix
branch
from
July 22, 2026 00:11
18500ff to
ccb89c8
Compare
sbc100
pushed a commit
that referenced
this pull request
Jul 22, 2026
This implements `recvmmsg` and `sendmmsg`, which were previously `ENOSYS` stubs. Per review feedback, the implementations now live in musl's `sendmmsg.c` and `recvmmsg.c` rather than the syscall stubs: `sendmmsg.c` already contained the emulation loop (previously gated behind `LONG_MAX > INT_MAX`), which is now also enabled under `__EMSCRIPTEN__`, and `recvmmsg.c` gains an equivalent `recvmsg` loop supporting `MSG_WAITFORONE` (timeouts report `ENOSYS`). Since nothing references the syscalls anymore, the `__syscall_recvmmsg`/`__syscall_sendmmsg` surface is removed entirely: the `UNIMPLEMENTED` stubs, the `SYS_` mappings in `arch/emscripten/bits/syscall.h`, the declarations in `emscripten/syscalls.h`, and their `native_sigs.py` entries. The `recvmsg` msghdr output fixes previously bundled here were split out into #27399. Adds `sockets.test_noderawsockets_mmsg` batching two datagrams out via `sendmmsg` and receiving them back in a single `recvmmsg` call. _Made with AI assistance under my review_
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.
This fixes three issues in the
recvmsgsyscall implementation for sockets, split out separately from #27395 per review feedback.The bugs:
HEAPU8.set(buf, iovbase + bytesRead)skipped ahead by the bytes already read into previous iovecs, corrupting all iovecs after the first.msg_namelenwas not updated to reflect the actual source address size.msg_controllenandmsg_flagswere left untouched rather than zeroed, leaving callers reading uninitialized values as control data / flags.Adds
sockets.test_noderawsockets_udp_recvmsgcovering a datagram scattered across two iovecs along with the msghdr output fields, verified failing before the fix.Made with AI assistance under my review