Tools to locate source of segmentation fault after callconv in bindings?

I’m trying to work through a Vulkan tutorial using Snektron’s bindings. I’m running into an issue where a function is causing a segmentation fault, I’m wondering if there’s any tools for zig that help locate the cause?

I’ve tracked the function in the bindings down to this, but not sure where to go next as it starts referencing calling out to vulkan (I think).

pub const PfnUpdateDescriptorSets = *const fn (
    device: Device,
    descriptor_write_count: u32,
    p_descriptor_writes: ?[*]const WriteDescriptorSet,
    descriptor_copy_count: u32,
    p_descriptor_copies: ?[*]const CopyDescriptorSet,
) callconv(vulkan_call_conv) void;

I’d imagine there’s an issue with the WriteDescriptorSet I’m passing, but not sure how to find out what part is the issue as the error is cryptic.

debug: Using device: Intel(R) Iris(TM) Graphics 6000
Segmentation fault at address 0x60
???:?:?: 0x1 in ??? (???)
Unwind information for `???:0x1` was not available, trace may be incomplete

???:?:?: 0x7ffa1d1d35fc in ??? (AppleIntelBDWGraphicsMTLDriver)
???:?:?: 0x116c29ab4 in ??? (libMoltenVK.dylib)
???:?:?: 0x116b867dd in ??? (libMoltenVK.dylib)
???:?:?: 0x116b8643e in ??? (libMoltenVK.dylib)
???:?:?: 0x116b98c97 in ??? (libMoltenVK.dylib)
???:?:?: 0x111b23240 in ??? (???)
???:?:?: 0x111b0abb4 in ??? (???)
???:?:?: 0x111ae0052 in ??? (???)
???:?:?: 0x111ae9942 in ??? (???)
???:?:?: 0x1272c752d in ??? (???)
???:?:?: 0x0 in ??? (???)

Try using a debugger, also reread the docs/examples/snippets you are using to see if it states any requirements and then check those requirements. Or any differences from examples/snippets.

…also make sure you have the validation layer enabled. I’d be surprised if the validation layer let’s any problems slip through which would then lead to a crash down in the Vulkan implementation:

4 Likes

Valgrind helps often a lot: https://valgrind.org/

For example: valgrind -s --leak-check=full --track-origins=yes <your programm>

Thanks, I’ll look into this. :slight_smile: