mach icon indicating copy to clipboard operation
mach copied to clipboard

gpu-dawn: undefined behavior caught by UBSAN affecting Windows (dawn binary: release-777728f)

Open michal-z opened this issue 2 years ago • 4 comments

This happens only in debug builds when creating (some) graphics pipelines. Windows 11, D3D12 backend.

Illegal instruction at address 0x7ff6a966b26d
D:\a\mach-gpu-dawn\mach-gpu-dawn\libs\dawn\src\dawn\native\stream\Stream.h:155:0: 0x7ff6a966b26d in awn::native::stream::Stream<D3D12_BLEND,void>::Write (dawn.lib)
D:\a\mach-gpu-dawn\mach-gpu-dawn\libs\dawn\src\dawn\native\stream\Stream.h:51:0: 0x7ff6a966b10f in awn::native::stream::StreamIn<D3D12_BLEND> (dawn.lib)
D:\a\mach-gpu-dawn\mach-gpu-dawn\libs\dawn\src\dawn\native\stream\Stream.h:74:0: 0x7ff6a966989a in awn::native::stream::StreamIn<int,int,D3D12_BLEND,D3D12_BLEND,D3D12_BLEND_OP,D3D12_BLEND,D3D12_BLEND,D3D12_BLEND_OP,D3D12_LOGIC_OP,unsigned char> (dawn.lib)

michal-z avatar Aug 13 '22 17:08 michal-z

👍

I'll need to find an example that reproduces this, haven't tested the latest version on Windows yet so maybe one already does - not sure.

emidoots avatar Aug 16 '22 00:08 emidoots

FYI this could also not be a bug in Dawn but rather just be signaling passing an object with the wrong memory layout to the API (maybe something wrong in your zgpu bindings?), that's happened to a few folks in the past.

emidoots avatar Aug 16 '22 00:08 emidoots

Will double check but keep in mind that release build works fine.

michal-z avatar Aug 16 '22 11:08 michal-z

I think that my bindings are fine. Also, note that debug builds on Linux and macOS work fine. It looks like the crash happens when blend field in below struct is null. According to the latest header this field is 'nullable' so it should work.

pub const ColorTargetState = extern struct {
    next_in_chain: ?*const ChainedStruct = null,
    format: TextureFormat,
    blend: ?*const BlendState = null,
    write_mask: ColorWriteMask = ColorWriteMask.all,
};

Anyway, this issue does not affect zig-gamedev project because we always use release binary of Dawn. I just wanted to let you know.

michal-z avatar Aug 16 '22 17:08 michal-z