Skip to content

Conversation

@leroycep
Copy link
Contributor

@leroycep leroycep commented Jan 14, 2025

from #22484, since apparently I can't reopen the old pr?


Alright, I've decided to give another go. I think I understood the problem better this time, otherwise the CI will inform me of my hubris.


main.zig:

pub const std = @import("std");

pub fn main() !void {
    std.debug.dumpCurrentStackTrace(null);
}

Compile using zig build-exe -target x86_64-windows-msvc ./main.zig and run using wine ./main.exe

Output before these changes:

Unable to dump stack trace: Unexpected

Output after these changes:

/home/geemili/code/zig/lib/std/debug.zig:198:31: 0x140001117 in dumpCurrentStackTrace (main.exe.obj)
        writeCurrentStackTrace(stderr, debug_info, io.tty.detectConfig(io.getStdErr()), start_addr) catch |err| {
                              ^
/main.zig:4:36: 0x140001015 in main (main.exe.obj)
/home/geemili/code/zig/lib/std/start.zig:475:53: 0x1400014aa in WinStartup (main.exe.obj)
    std.os.windows.ntdll.RtlExitUserProcess(callMain());
                                                    ^
???:?:?: 0x6fffffa547f8 in ??? (kernel32.dll)
???:?:?: 0x6fffffc2f93a in ??? (ntdll.dll)

It seems like it's failing to find the location of main.zig, but that's a mystery for another time.

  • Wine version: wine-9.22

#17535 is a related issue. Compiling Zig with these changes to the standard library fixes the original error message, but replaced it with another error (as well as a now-working backtrace 😁) that comes from an unimplemented feature in wine:

~/Downloads/zig-wine-backtraces/invoking-zig-cc-17535> wine ../zig-windows-x86_64-0.14.0-dev.2643+fb43e91b2/zig.exe build-exe main.zig
error: unable to find zig self exe path: Unexpected
~/Downloads/zig-wine-backtraces/invoking-zig-cc-17535> wine ~/code/zig/build/stage4-windows/bin/zig.exe build-exe main.zig
0184:fixme:file:NtLockFile Unimplemented yet parameter
error.Unexpected NTSTATUS=0xc0000002
/home/geemili/code/zig/lib/std/os/windows.zig:2093:40: 0x14023a46f in LockFile (zig.exe.obj)
        else => return unexpectedStatus(rc),
                                       ^
/home/geemili/code/zig/lib/std/fs/Dir.zig:1099:19: 0x1401ad675 in createFileW (zig.exe.obj)
    try w.LockFile(
                  ^
/home/geemili/code/zig/lib/std/fs/Dir.zig:968:32: 0x140055eac in createFile (zig.exe.obj)
        return self.createFileW(path_w.span(), flags);
                               ^
/home/geemili/code/zig/src/Zcu/PerThread.zig:134:33: 0x140835003 in astGenFile (zig.exe.obj)
        break zir_dir.createFile(&hex_digest, .{
                                ^
/home/geemili/code/zig/src/Compilation.zig:4253:18: 0x14052157a in workerAstGenFile (zig.exe.obj)
    pt.astGenFile(file, path_digest) catch |err| switch (err) {
                 ^
/home/geemili/code/zig/lib/std/Thread/Pool.zig:178:50: 0x140521cce in runFn (zig.exe.obj)
            @call(.auto, func, .{id.?} ++ closure.arguments);
                                                 ^
/home/geemili/code/zig/lib/std/Thread/Pool.zig:291:32: 0x1404dad5e in worker (zig.exe.obj)
            run_node.data.runFn(&run_node.data, id);
                               ^
/home/geemili/code/zig/lib/std/Thread.zig:486:13: 0x140300e6c in callFn__anon_179210 (zig.exe.obj)
            @call(.auto, f, args);
            ^
/home/geemili/code/zig/lib/std/Thread.zig:599:30: 0x1401abf1e in entryFn (zig.exe.obj)
                return callFn(f, self.fn_args);
                             ^
???:?:?: 0x6fffffa547f8 in ??? (kernel32.dll)
???:?:?: 0x6fffffc2f93a in ??? (ntdll.dll)
Z:\home\geemili\code\zig\lib\std\std.zig:1:1: error: unable to load 'Z:\home\geemili\code\zig\lib\std/std.zig': Unexpected

Running the test suite under wine also had a couple tests fail, presumably from similar issues. Hard to say without running it on Microsoft Windows.

@squeek502
Copy link
Member

The first commit is a duplicate of #17541

@leroycep
Copy link
Contributor Author

I see.

@mlugg
Copy link
Member

mlugg commented Sep 9, 2025

Ha, I was wondering what was causing x86_64-windows stack traces not to work under Wine! Thanks for this work. I'll cherry-pick the first commit into my branch (I already have an equivalent diff to the second).

@squeek502
Copy link
Member

squeek502 commented Sep 9, 2025

@mlugg #17541 contains a better version of the first commit IMO

@mlugg
Copy link
Member

mlugg commented Sep 9, 2025

Ah, okay, thanks. Since the diff will merge cleanly either way, I'll leave it out my branch for now.

@squeek502
Copy link
Member

squeek502 commented Nov 24, 2025

Thanks for working on this, but I'm going to close it as it's now obsolete. The GetFinalPathNameByHandle change is included in #17541, and the SelfInfo change is included in #25227

@squeek502 squeek502 closed this Nov 24, 2025
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

Successfully merging this pull request may close these issues.

3 participants