-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
x/io, x/os: async i/o reactor, cross-platform socket syscalls and bits #8750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
On Azure CI on x86_64-linux-musl, it seems that: sendmsg(
socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP),
const * struct msghdr {
iovecs: [ "hello", " world" ],
iovecs_len: 2,
// ... everything else is zeroed
},
0,
)for some reason returns EMSGSIZE. The test code is: const message = "hello world";
_ = try conn.client.writeVectorized(Socket.Message.fromBuffers(&[_]Buffer{
Buffer.from(message[0 .. message.len / 2]),
Buffer.from(message[message.len / 2 ..]),
}), 0);The full stack trace is: Might anyone know what could be the cause? My hunch is that it may be an ABI issue with the layout of Running the test with the target locally on my Linux laptop passes. All other CI targets pass. cc @LemonBoy @daurnimator @ifreund EDIT: Here's the |
|
I can't reproduce the problem locally, try adding some debug prints to see what the msghdr contents are before it's passed to the kernel. |
|
@LemonBoy printed out the |
b6de155 to
0ff81a7
Compare
|
Still haven't figured out how to get the Azure CI Linux target passing for The The size of the The socket write buffer size is 2626560 bytes, which is the same on my laptop; so I assume that patches made by Azure aren't interfering with any settings to do with stream sockets. Yet, sendmsg() still returns EMSGSIZE. Is there any way to, for example, enable strace in the CI or to emulate the environment locally? Or, might anyone have any other ideas in mind on what could be wrong? |
|
You're ignoring a pretty huge detail here: qrmu |
Thanks for the link, it finally makes a lot of sense 😌. Looks like the only way around it is to patch qemu on CI to zero out the msghdr struct though. @kubkon @andrewrk is patching and building qemu for CI something desirable? Or might there be any other quick workarounds for this? |
Consider sending a patch upstream. cc @mikdusan as he was considering an upgrade to Qemu 6.0 |
I wouldn't be against patching qemu here before it shows up in upstream releases but if you want to pursue this angle I'd need to check first with andrew. Let me know if this is the case. Side note: also unknown is if 6.0.0 needs patching wrt this issue. Ie: would an upgrade to 6.0.0 just fix things for you. Side note 2: #8653 has a link to 6.0.0 tarball if you can test locally . |
|
6.0 has the same problem, the problem was never patched nor reported upstream |
|
Patching is acceptable if we first send the patch upstream |
|
Sent a patch upstream to QEMU here: https://patchew.org/QEMU/[email protected]/ Should I make a PR to add the patch to the custom QEMU w/ patches that Zig uses now? |
|
@lithdew yes please add a PR at https://github.com/ziglang/qemu-static |
Refer to this PR for more details about this patch: ziglang/zig#8750 Some spacing has also been added to the existing patch to adhere to QEMU's code style guide.
Refer to this PR for more details about this patch: ziglang/zig#8750 Some spacing has also been added to the existing patch to adhere to QEMU's code style guide.
- apply patch for qemu-user syscall do_sendrecvmsg_locked - see ziglang#8750
- apply patch for qemu-user syscall do_sendrecvmsg_locked - see #8750
|
All tests are finally passing on CI 😄. ... except Drone though, looks like something's up with Drone CI for recent commits/PR's. |
Yep, Drone seems unable to connect to Github lately. |
7c77f39 to
c5bcfd4
Compare
|
All CI tests are passing! 😄 |
|
Rebased with master to fix merge conflicts. |
5cec5c3 to
c28f3ff
Compare
Cross-platform versions of msghdr, sendmsg, recvmsg, linger, and iovec were provided based on findings from glibc, musl, and Microsoft's documentation. Implemented initial Reactor interface for epoll (linux) which wraps around I/O reactor subsystems such as epoll, kqueue, select, etc. across different platforms. The Reactor interface allows for driving async I/O in Zig applications. A test was added for the Reactor interface to drive a TCP client/listener socket pair. A greatest-common-subset of possible socket initialization flags (close socket on exec syscalls, initialize socket to be non-blocking) were implemented. A test was added for using sendmsg/recvmsg syscalls across different platforms for a TCP client/listener socket pair.
`msghdr` and `msghdr_const` definitions have been added back the way they were in std.os. std.os.sendmsg has also been modified to accept a msghdr_const again to ensure backwards-compatibility with this PR. Underneath the hood, std.os.sendmsg will @ptrCast the provided msghdr_const into a std.x.os.Socket.Message. `sockaddr_storage` definitions have been added back the way they were in std.os, except that it now simply aliases std.x.os.Socket.Address.Native.Storage as all of std.x.os.Socket.Address.Native.Storage's fields are equivalent to the fields that were previously defined for std.x.os.bits.sockaddr_storage. std.x.os.Socket.sendMessage now no longer is a stub that aliases std.os.sendmsg, but instead calls and handles errors from std.os.system.sendmsg directly. Addresses feedback to urge backwards compatibility from @andrewrk.
|
All CI tests are now passing 😄. |
Cross-platform versions of msghdr, sendmsg, recvmsg, linger, and iovec were provided based on findings from glibc, musl, and Microsoft's documentation.
Implemented initial Reactor interface for epoll (linux) which wraps around I/O reactor subsystems such as epoll, kqueue, select, etc. across different platforms. The Reactor interface allows for driving async I/O in Zig applications.
A test was added for the Reactor interface to drive a TCP client/listener socket pair.
A greatest-common-subset of possible socket initialization flags (close socket on exec syscalls, initialize socket to be non-blocking) were implemented.
A test was added for using sendmsg/recvmsg syscalls across different platforms for a TCP client/listener socket pair.