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

[Bug] Silent Fail Windows #35

Closed
KeithBrown39423 opened this issue Jun 7, 2024 · 5 comments
Closed

[Bug] Silent Fail Windows #35

KeithBrown39423 opened this issue Jun 7, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@KeithBrown39423
Copy link
Owner

Describe the bug
When running the Windows binary, if you specify a filename, it silently fails with the error code -1073741819.
It also takes around 15-25 seconds before it actually fails. When running it on WSL, it gives the error code 5.

To Reproduce
Steps to reproduce the behavior:

  1. Run hexdump.exe <file>
  2. Run echo %ERRORLEVEL% to see the error code.

Expected behavior
Printing out the hexdump of the specified file.

Screenshots
image

Desktop (please complete the following information):

  • Windows 11 Version 23H2 OS Build 22631.3593
  • WSL Arch Linux Version 24.4.28.0
@KeithBrown39423 KeithBrown39423 added the bug Something isn't working label Jun 7, 2024
@KeithBrown39423 KeithBrown39423 self-assigned this Jun 7, 2024
@KeithBrown39423
Copy link
Owner Author

KeithBrown39423 commented Jun 7, 2024

Here are the results from the Windows event viewer if it helps

Faulting module name: hexdump.exe, version: 0.0.0.0, time stamp: 0x666340b7
Exception code: 0xc0000005
Fault offset: 0x00000000000036b0
Faulting process id: 0x0x5874
Faulting application start time: 0x0x1DAB8FF685921DD
Faulting application path: \\wsl.localhost\Arch\home\keith\projects\zig\Hexdump\release\x86_64\windows\bin\release\x86_64\windows\bin\hexdump.exe
Faulting module path: \\wsl.localhost\Arch\home\keith\projects\zig\Hexdump\release\x86_64\windows\bin\release\x86_64\windows\bin\hexdump.exe
Report Id: 3740cd5a-6b13-4374-8e4b-54b3616f52af
Faulting package full name: 
Faulting package-relative application ID:
Faulting application name: hexdump.exe, version: 0.0.0.0, time stamp: 0x66613a70
Faulting module name: hexdump.exe, version: 0.0.0.0, time stamp: 0x66613a70
Exception code: 0xc0000005
Fault offset: 0x00000000000036b0
Faulting process id: 0x0x64BC
Faulting application start time: 0x0x1DAB8FE4C51C9E7
Faulting application path: C:\Users\keith\Downloads\hexdump.exe
Faulting module path: C:\Users\keith\Downloads\hexdump.exe
Report Id: deedc38f-cab4-4ff1-8d55-cf70f3e5ceb1
Faulting package full name: 
Faulting package-relative application ID:

@ZackeryRSmith
Copy link
Contributor

I'll test this once I get home. I have a feeling this may be a system dependent error.

@ZackeryRSmith
Copy link
Contributor

Nevermind same issue here...

@ZackeryRSmith
Copy link
Contributor

2 things I've noticed off the bat. Two issues where you're treating a u64 as usize. Keep in mind usize doesn't always mean a u64, as 32-bit systems will use u32. This is done on lines

for (0..lines) |line_index| {
for (0..(if (length < 16) length else 16)) |i| {

These can be fixed by wrapping the variable in a @intCast

Now the program won't exit silently, actually now it's quite "loud". As a segmentation fault occurs.

Segmentation fault at address 0x59002c
C:\Users\zacke\OneDrive\Desktop\zig-windows-x86-0.12.0\lib\std\unicode.zig:1563:33: 0x4d49f0 in wtf8ValidateSlice (hexdump.exe.obj)
    return utf8ValidateSliceImpl(input, .can_encode_surrogate_half);
                                ^
C:\Users\zacke\OneDrive\Desktop\zig-windows-x86-0.12.0\lib\std\unicode.zig:1623:31: 0x49ae8a in init (hexdump.exe.obj)
        if (!wtf8ValidateSlice(s)) {
                              ^
C:\Users\zacke\OneDrive\Desktop\zig-windows-x86-0.12.0\lib\std\unicode.zig:1235:56: 0x49a72f in utf8ToUtf16LeImpl__anon_6188 (hexdump.exe.obj)
        .can_encode_surrogate_half => try Wtf8View.init(remaining),
                                                       ^
C:\Users\zacke\OneDrive\Desktop\zig-windows-x86-0.12.0\lib\std\unicode.zig:1742:29: 0x48d595 in wtf8ToWtf16Le (hexdump.exe.obj)
    return utf8ToUtf16LeImpl(wtf16le, wtf8, .can_encode_surrogate_half);
                            ^
C:\Users\zacke\OneDrive\Desktop\zig-windows-x86-0.12.0\lib\std\os\windows.zig:2268:50: 0x48369e in sliceToPrefixedFileW (hexdump.exe.obj)
    temp_path.len = try std.unicode.wtf8ToWtf16Le(&temp_path.data, path);
                                                 ^
C:\Users\zacke\OneDrive\Desktop\zig-windows-x86-0.12.0\lib\std\fs\Dir.zig:800:56: 0x4778c1 in openFile (hexdump.exe.obj)
        const path_w = try windows.sliceToPrefixedFileW(self.fd, sub_path);
                                                       ^
C:\Users\zacke\Downloads\Hexdump-release\src\main.zig:48:35: 0x47416d in main (hexdump.exe.obj)
    const file = fs.cwd().openFile(args.file, .{}) catch |err| {
                                  ^
C:\Users\zacke\OneDrive\Desktop\zig-windows-x86-0.12.0\lib\std\start.zig:350:53: 0x478b6c in WinStartup (hexdump.exe.obj)
    std.os.windows.ntdll.RtlExitUserProcess(callMain());
                                                    ^
???:?:?: 0x7505fcc8 in ??? (KERNEL32.DLL)
???:?:?: 0x771a7cbd in ??? (ntdll.dll)
???:?:?: 0x771a7c8d in ??? (ntdll.dll)

KeithBrown39423 added a commit that referenced this issue Jun 9, 2024
@KeithBrown39423
Copy link
Owner Author

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants