Skip to content

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

@marler8997

Description

@marler8997

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    os-windowsMicrosoft Windowsstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions