Skip to content

fix backtraces produced by standard library under Wine #22492

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/std/debug/SelfInfo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ fn readCoffDebugInfo(allocator: Allocator, coff_obj: *coff.Coff) !Module {
di.dwarf = dwarf;
}

const raw_path = try coff_obj.getPdbPath() orelse return di;
const raw_path = (coff_obj.getPdbPath() catch return error.InvalidDebugInfo) orelse return di;
const path = blk: {
if (fs.path.isAbsolute(raw_path)) {
break :blk raw_path;
Expand Down
12 changes: 12 additions & 0 deletions lib/std/os/windows.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,18 @@ pub fn GetFinalPathNameByHandle(
return final_path;
},
.Dos => {
// The "\??\" directory contains a bunch of symlinks that translates DOS volume names (like "C:")
// into NT volume names (like "\Device\HarddiskVolume2"). However, we want the DOS volume name, so
// we can just strip the "\??\" and return the subpath into that directory.
//
// Based on:
// - this stackoverflow post https://stackoverflow.com/questions/23041983/path-prefixes-and
// - downloading the WinObj program and inspecting the contents of "\??\"
const nt_device_alias_directory_prefix = std.unicode.utf8ToUtf16LeStringLiteral("\\??\\");
if (mem.startsWith(u16, final_path, nt_device_alias_directory_prefix)) {
return final_path[nt_device_alias_directory_prefix.len..];
}

// parse the string to separate volume path from file path
const expected_prefix = std.unicode.utf8ToUtf16LeStringLiteral("\\Device\\");

Expand Down
Loading