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

windows 11 error.Unexpected: GetLastError(10050): A socket operation encountered a dead network #6

Open
yzn-h opened this issue Sep 4, 2023 · 1 comment

Comments

@yzn-h
Copy link

yzn-h commented Sep 4, 2023

I'm trying to compile and run example.zig on windows 11 but when I compile example.zig with zig build-exe example.zig there is no errors
but when I run it I get this error

.\example.exe
error.Unexpected: GetLastError(10050): A socket operation encountered a dead network.

C:\Users\yznha\zig\master\lib\std\os\windows.zig:2583:27: 0x7ff63e561486 in unexpectedWSAError (example.exe.obj)
    return unexpectedError(@as(Win32Error, @enumFromInt(@intFromEnum(err))));
                          ^
C:\Users\yznha\zig\master\lib\std\os.zig:3980:60: 0x7ff63e5618e2 in connect (example.exe.obj)
            else => |err| return windows.unexpectedWSAError(err),
                                                           ^
C:\Users\yznha\projects\zigx\x.zig:383:15: 0x7ff63e56161f in connectUnixAddr (example.exe.obj)
    os.connect(sock, @ptrCast(addr), addr_len) catch |err| switch (err) {
              ^
C:\Users\yznha\projects\zigx\x.zig:364:27: 0x7ff63e561be3 in connectUnixDisplayNum (example.exe.obj)
    return connectUnixAddr(&addr, path.len);
                          ^
C:\Users\yznha\projects\zigx\x.zig:304:37: 0x7ff63e563ec5 in connectExplicit (example.exe.obj)
        return connectUnixDisplayNum(display_num) catch |err| switch (err) {
                                    ^
C:\Users\yznha\projects\zigx\x.zig:263:27: 0x7ff63e5645b1 in connect (example.exe.obj)
    return connectExplicit(optional_host, optional_proto, parsed.display_num);
                          ^
C:\Users\yznha\projects\zigx\common.zig:29:27: 0x7ff63e5658ea in connect (example.exe.obj)
    const sock = x.connect(display) catch |err| {
                          ^
C:\Users\yznha\projects\zigx\example.zig:13:36: 0x7ff63e56836d in main (example.exe.obj)
    const conn = try common.connect(allocator);
                                   ^
C:\Users\yznha\zig\master\lib\std\start.zig:347:37: 0x7ff63e56c053 in WinStartup (example.exe.obj)

                                    ^
???:?:?: 0x7ffb0d0d257c in ??? (KERNEL32.DLL)
???:?:?: 0x7ffb0e28aa67 in ??? (ntdll.dll)
thread 17704 panic: TODO: connect failed with error.Unexpected, need to implement fallback to TCP
C:\Users\yznha\zig\master\lib\std\debug.zig:373:22: 0x7ff63e56eba4 in panicExtra__anon_5892 (example.exe.obj)
    std.builtin.panic(msg, trace, ret_addr);
                     ^
C:\Users\yznha\zig\master\lib\std\debug.zig:348:15: 0x7ff63e561b3c in panic__anon_4778 (example.exe.obj)
    panicExtra(null, null, format, args);
              ^
C:\Users\yznha\projects\zigx\x.zig:389:28: 0x7ff63e56168f in connectUnixAddr (example.exe.obj)
            std.debug.panic("TODO: connect failed with {}, need to implement fallback to TCP", .{e});
                           ^
C:\Users\yznha\projects\zigx\x.zig:364:27: 0x7ff63e561be3 in connectUnixDisplayNum (example.exe.obj)
    return connectUnixAddr(&addr, path.len);
                          ^
C:\Users\yznha\projects\zigx\x.zig:304:37: 0x7ff63e563ec5 in connectExplicit (example.exe.obj)
        return connectUnixDisplayNum(display_num) catch |err| switch (err) {
                                    ^
C:\Users\yznha\projects\zigx\x.zig:263:27: 0x7ff63e5645b1 in connect (example.exe.obj)
    return connectExplicit(optional_host, optional_proto, parsed.display_num);
                          ^
C:\Users\yznha\projects\zigx\common.zig:29:27: 0x7ff63e5658ea in connect (example.exe.obj)
    const sock = x.connect(display) catch |err| {
                          ^
C:\Users\yznha\projects\zigx\example.zig:13:36: 0x7ff63e56836d in main (example.exe.obj)
    const conn = try common.connect(allocator);
                                   ^
C:\Users\yznha\zig\master\lib\std\start.zig:347:37: 0x7ff63e56c053 in WinStartup (example.exe.obj)

                                    ^
???:?:?: 0x7ffb0d0d257c in ??? (KERNEL32.DLL)
???:?:?: 0x7ffb0e28aa67 in ??? (ntdll.dll)
@marler8997
Copy link
Owner

marler8997 commented Sep 11, 2023

I ran into this same error on my windows machine when I set my DISPLAY environment variable to :0. As you can see from the stack trace, we're calling connectUnixDisplayNum, which causes us to try and create a unix socket which won't work on windows.

I'm actually not sure how the various X Servers on windows (like MobaXTERM) expect applications to interpret DISPLAY :0 so for now I've just pushed a commit that will print this error message:

error: unsure how to connect to DISPLAY :0 on windows, how about specifing a hostname? i.e. localhost:0

If anyone can find out how :0 is actually supposed to behave on windows let me know and I'll implement it. It's likely there's actually no standard here since I'm not sure it's common for X applications to actually run on native windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants