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

No error reported to user when segfault occurs with windows Subsystem #7645

Open
marler8997 opened this issue Jan 1, 2021 · 0 comments
Open
Labels
os-windows standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@marler8997
Copy link
Contributor

The following application will produce an access violation on windows, and when compiling with the "windows" subsystem, will not report any error to the user:

const std = @import("std");
const w = std.os.windows;

pub extern "user32" fn MessageBoxA (
    hWnd: ?w.HWND,
    lpText: [*:0]const u8,
    lpCaption: [*:0]const u8,
    uType: u32,
) callconv(w.WINAPI) c_int;

pub export fn wWinMainCRTStartup() callconv(w.WINAPI) noreturn {
    // comment out the next line to show that the program works and produces a message box
    (@intToPtr(fn() void, 1))();
    _ = MessageBoxA(null, "Hello", "We are here", 0);
    w.kernel32.ExitProcess(0);
}

Here's how to build:

zig build-exe bug.zig --single-threaded --subsystem windows

Note that when the --subsystem windows arguments are removed, it will popup an error window and provide the user a chance to debug the problem. The problem is that when using the "windows" subsystem, process just dies with no information and no error reported to the user.

@andrewrk andrewrk added the standard library This issue involves writing Zig code for the standard library. label Jan 3, 2021
@andrewrk andrewrk added this to the 0.9.0 milestone Jan 3, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os-windows standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

3 participants