ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.58k stars 2.45k forks source link

flaky test: 'non-blocking tcp server' #18315

Open andrewrk opened 8 months ago

andrewrk commented 8 months ago
+ stage3/bin/zig build test docs --zig-lib-dir /Users/runner/work/zig/zig/build/../lib -Denable-macos-sdk -Dstatic-llvm -Dskip-non-native --search-prefix /Users/runner/zig+llvm+lld+clang-x86_64-macos-none-0.12.0-dev.467+0345d7866
run test std-native-ivybridge-ReleaseFast-single: error: 'test.non-blocking tcp server' failed
run test std-native-ivybridge-ReleaseFast-single: error: while executing test 'test.ampersand', the following test command failed:
/Users/runner/work/zig/zig/build/zig-local-cache/o/c9d87893bf46b60e4e09678c34c57445/test --listen=- 
Build Summary: 5380/5514 steps succeeded; 131 skipped; 1 failed; 46052/48334 tests passed; 2281 skipped; 1 failed (disable with --summary none)
test transitive failure
+- test-std transitive failure
   +- run test std-native-ivybridge-ReleaseFast-single 2485/2588 passed, 1 failed, 102 skipped
error: the following build command failed with exit code 1:
/Users/runner/work/zig/zig/build/zig-local-cache/o/20256f6be3c8217f45346526c9dc2963/build /Users/runner/work/zig/zig/build/stage3/bin/zig /Users/runner/work/zig/zig /Users/runner/work/zig/zig/build/zig-local-cache /Users/runner/work/zig/zig/build/zig-global-cache --seed 0x60b4f065 test docs --zig-lib-dir /Users/runner/work/zig/zig/build/../lib -Denable-macos-sdk -Dstatic-llvm -Dskip-non-native --search-prefix /Users/runner/zig+llvm+lld+clang-x86_64-macos-none-0.12.0-dev.467+0345d7866

Also look into why it's printing while executing test 'test.ampersand',.

matu3ba commented 8 months ago

Copied from https://github.com/ziglang/zig/pull/18305#issuecomment-1862850103: The stack trace looks broken, but one can guess that the error is in os.accept and some unreachable is reached

Install the project...
-- Install configuration: "Release"
++ pwd
+ stage3/bin/zig build test docs --zig-lib-dir /Users/runner/work/zig/zig/build/../lib -Denable-macos-sdk -Dstatic-llvm -Dskip-non-native --search-prefix /Users/runner/zig+llvm+lld+clang-x86_64-macos-none-0.12.0-dev.467+0345d7866
run test std-native-ivybridge-ReleaseSafe-single: error: 'test.non-blocking tcp server' failed: /Users/runner/work/zig/zig/lib/std/os.zig:0:0: 0x105c3fd5a in accept (test)
/Users/runner/work/zig/zig/lib/std/net.zig:2033:13: 0x105c3fd62 in accept (test)
            return err;
            ^
/Users/runner/work/zig/zig/lib/std/os.zig:0:0: 0x105c3fd5a in accept (test)
/Users/runner/work/zig/zig/lib/std/net.zig:2033:13: 0x105c3fd62 in accept (test)
            return err;
            ^
/Users/runner/work/zig/zig/lib/std/net/test.zig:0:0: 0x105c3fa49 in test.non-blocking tcp server (test)
run test std-native-ivybridge-ReleaseSafe-single: error: while executing test 'test.ampersand', the following test command failed:
/Users/runner/work/zig/zig/build/zig-local-cache/o/c6a10302cf28730bb0a6aec75c00f7d3/test --listen=- 
Build Summary: 5380/5514 steps succeeded; 131 skipped; 1 failed; 46052/48334 tests passed; 2281 skipped; 1 failed (disable with --summary none)
test transitive failure
+- test-std transitive failure
   +- run test std-native-ivybridge-ReleaseSafe-single 2485/2588 passed, 1 failed, 102 skipped
error: the following build command failed with exit code 1:
/Users/runner/work/zig/zig/build/zig-local-cache/o/d4f344701f1c5fa7022a20e1166480b2/build /Users/runner/work/zig/zig/build/stage3/bin/zig /Users/runner/work/zig/zig /Users/runner/work/zig/zig/build/zig-local-cache /Users/runner/work/zig/zig/build/zig-global-cache --seed 0x3b2b3667 test docs --zig-lib-dir /Users/runner/work/zig/zig/build/../lib -Denable-macos-sdk -Dstatic-llvm -Dskip-non-native --search-prefix /Users/runner/zig+llvm+lld+clang-x86_64-macos-none-0.12.0-dev.467+0345d7866

Possible cases

            switch (errno(rc)) {
                .SUCCESS => {
                    break @as(socket_t, @intCast(rc));
                },
                .INTR => continue,
                .AGAIN => return error.WouldBlock,
                .BADF => unreachable, // always a race condition
                .CONNABORTED => return error.ConnectionAborted,
                .FAULT => unreachable,
                .INVAL => return error.SocketNotListening,
                .NOTSOCK => unreachable,
                .MFILE => return error.ProcessFdQuotaExceeded,
                .NFILE => return error.SystemFdQuotaExceeded,
                .NOBUFS => return error.SystemResources,
                .NOMEM => return error.SystemResources,
                .OPNOTSUPP => unreachable,
                .PROTO => return error.ProtocolFailure,
                .PERM => return error.BlockedByFirewall,
                else => |err| return unexpectedErrno(err),
            }

If I had to guess, I'd think that OPNOTSUPP may not be unreachable listed here https://github.com/apple/darwin-xnu/blob/main/bsd/man/man2/accept.2.

However, I have no idea why it always fails during execution of test ampersand. Afaiu, the test server uses a fifo, so there should be no socket involved potentially affecting the test aside of the potential sockets inside std.net.test.