Skip to content
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

Compile error "NetworkSubsystemFailed not handled in switch" in reading file in io_mode = .evented #6794

Closed
marnix opened this issue Oct 24, 2020 · 7 comments · Fixed by #6827
Labels
bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@marnix
Copy link

marnix commented Oct 24, 2020

The code below compiles fine with Zig 0.6.0, but fails to compile with error "NetworkSubsystemFailed not handled in switch" in std/event/loop.zig, with latest master (0.6.0+91a1c20e7). (This is on Linux.)

build.zig:

const Builder = @import("std").build.Builder;
pub fn build(b: *Builder) void {
    var exe = b.addExecutable("x", "x.zig");
    b.default_step.dependOn(&exe.step);
}

x.zig:

pub const io_mode = .evented;
const std = @import("std");
pub fn main() !void {
    const f = try std.fs.cwd().openFile("smallfile.txt", .{});
    var buffer: [100]u8 = undefined;
    _ = try f.readAll(&buffer);
}

The compile error is

$ zig build
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/event/loop.zig:468:60: error: error.NetworkSubsystemFailed not handled in switch
                    _ = os.poll(&pfd, -1) catch |poll_err| switch (poll_err) {
                                                           ^
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/event/loop.zig:474:37: note: referenced here
                            std.time.sleep(1 * std.time.ns_per_ms);
                                    ^
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/event/loop.zig:443:39: note: referenced here
        defer if (need_to_delete) self.linuxRemoveFd(fd);
                                      ^
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/event/loop.zig:432:63: note: referenced here
    pub fn linuxWaitFd(self: *Loop, fd: i32, flags: u32) void {
                                                              ^
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/event/loop.zig:1009:49: note: when analyzing type '@Frame(std.event.loop.Loop.read)' here
                        self.waitUntilFdReadable(fd);
                                                ^
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/fs/file.zig:422:50: note: while checking if 'std.fs.file.File.read' is async
            return std.event.Loop.instance.?.read(self.handle, buffer, self.capable_io_mode != self.intended_io_mode);
                                                 ^
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/fs/file.zig:431:38: note: while checking if 'std.fs.file.File.readAll' is async
            const amt = try self.read(buffer[index..]);
                                     ^
./x.zig:6:22: note: when analyzing type '@Frame(main)' here
    _ = try f.readAll(&buffer);
                     ^
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/start.zig:326:37: note: while checking if 'std.start.callMain' is async
            const result = root.main() catch |err| {
                                    ^
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/lib/zig/std/start.zig:259:48: note: referenced here
            var frame: @Frame(callMainAsync) = undefined;
                                               ^
x...The following command exited with error code 1:
/home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/zig build-exe /media/marnux3data/data/projects/zig-mm/tmp/x.zig --cache-dir /media/marnux3data/data/projects/zig-mm/tmp/zig-cache --name x --enable-cache
error: the following build command failed with exit code 1:
/media/marnux3data/data/projects/zig-mm/tmp/zig-cache/o/c661213d782e893ae2ae2b6dfdeabc0e/build /home/marnix/bin/zig-linux-x86_64-0.6.0+91a1c20e7/zig /media/marnux3data/data/projects/zig-mm/tmp /media/marnux3data/data/projects/zig-mm/tmp/zig-cache
@marnix
Copy link
Author

marnix commented Oct 24, 2020

This might have been triggered by 127fa80 in recently merged #6237.

@LemonBoy
Copy link
Contributor

Another reason to let std.os rot in hell (#6600), windows WSAPoll works for sockets only, while the Unix counterpart works with any kind of file.

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library. labels Oct 25, 2020
@Vexu Vexu added this to the 0.8.0 milestone Oct 25, 2020
marnix added a commit to marnix/zig that referenced this issue Oct 26, 2020
@marnix
Copy link
Author

marnix commented Oct 27, 2020

I closed my PR #6826 in favor of #6827 which is better and also solves this issue.

@heidezomp
Copy link
Contributor

@marnix Sorry for not noticing your open issue and PR! I usually look for open issues/PRs before opening one myself but I guess I was lazy yesterday.

@marnix
Copy link
Author

marnix commented Oct 27, 2020

@marnix Sorry for not noticing your open issue and PR! I usually look for open issues/PRs before opening one myself but I guess I was lazy yesterday.

No problem at all! Your PR was better at making this case unreachable, so that's why I closed mine.

@heidezomp
Copy link
Contributor

Even though my PR is still undecided #6827 (comment), this issue can already be closed since it was fixed independently in 1b34365.

@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@marnix
Copy link
Author

marnix commented Nov 7, 2020

Even though my PR is still undecided #6827 (comment), this issue can already be closed since it was fixed independently in 1b34365.

Agree, double-checked that fix earlier today, closing. Thanks!

@marnix marnix closed this as completed Nov 7, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.7.0 Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior standard library This issue involves writing Zig code for the standard library.
Projects
None yet
5 participants