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

Closed
opened 2022-08-13 17:19:46 +00:00 by michal-z · 4 comments
michal-z commented 2022-08-13 17:19:46 +00:00 (Migrated from github.com)

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)
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) ```
emidoots commented 2022-08-16 00:13:58 +00:00 (Migrated from github.com)

👍

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.

👍 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 commented 2022-08-16 00:18:10 +00:00 (Migrated from github.com)

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.

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.
michal-z commented 2022-08-16 11:19:28 +00:00 (Migrated from github.com)

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

Will double check but keep in mind that release build works fine.
michal-z commented 2022-08-16 17:37:38 +00:00 (Migrated from github.com)

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.

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. ```zig 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#456
No description provided.