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

fix backtraces produced by standard library under Wine #22492

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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
Collaborator

The first commit is a duplicate of #17541

@leroycep
Copy link
Contributor Author

I see.

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.

2 participants