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

loading base handle crashes in release #1

Closed
Avokadoen opened this issue Nov 26, 2021 · 2 comments
Closed

loading base handle crashes in release #1

Avokadoen opened this issue Nov 26, 2021 · 2 comments

Comments

@Avokadoen
Copy link

Avokadoen commented Nov 26, 2021

This is the same issue that zig_vulkan is currently suffering from.
Building in debug works fine, but when building a release build it will fail to load the base handle at these lines

graphics_context.zig: line 98-99

const vk_proc = @ptrCast(fn(instance: vk.Instance, procname: [*:0]const u8) vk.PfnVoidFunction, glfw.getInstanceProcAddress);
self.vkb = try BaseDispatch.load(vk_proc);

Terminal:

$ zig build run -Drelease-safe
thread 1030138 panic: reached unreachable code
The following command terminated unexpectedly:
cd /home/aksel/Projects/mach-glfw-vulkan-example && /home/aksel/Projects/mach-glfw-vulkan-example/zig-out/bin/mach-glfw-vulkan-example 
error: the following build command failed with exit code 1:
/home/aksel/Projects/mach-glfw-vulkan-example/zig-cache/o/9eb30b7963903b666b1f2550cdaaa19e/build /snap/zig/4321/zig /home/aksel/Projects/mach-glfw-vulkan-example /home/aksel/Projects/mach-glfw-vulkan-example/zig-cache /home/aksel/.cache/zig run -Drelease-safe
@Avokadoen
Copy link
Author

Seems like replacing the mach implementation resolved the issue:

replace

pub fn getInstanceProcAddress(vk_instance: ?*opaque {}, proc_name: [*:0]const u8) callconv(.C) ?VKProc {
    const proc_address = c.glfwGetInstanceProcAddress(if (vk_instance) |v| @ptrCast(c.VkInstance, v) else null, proc_name);
    getError() catch |err| @panic(@errorName(err));
    if (proc_address) |addr| return addr;
    return null;
}

with

pub const getInstanceProcAddress = c.glfwGetInstanceProcAddress;

@Avokadoen
Copy link
Author

Fix described by @InKryption here

@slimsag slimsag closed this as completed in 5e510a7 Dec 7, 2021
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

No branches or pull requests

1 participant