[SPIR-V] Segfault: `vk::SpirvType` pointer as a push-constant member

Open
#9,054 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp
Domain
compilers

Research direction

Start with the SPIR-V code path that lowers vk::SpirvType members in push constants, then reproduce the crash using the HLSL snippet and flags in the issue. Compare the generated layout and memory model with the expected Offset 8 and PhysicalStorageBuffer64; done means compilation succeeds without a segfault and produces those results.

Written by the indexing model from the issue text.

Description

bug needs-triage spirv

Version: DXC trunk (Compiler Explorer)
Flags: -spirv -T cs_6_8 -E main -HV 202x -fspv-target-env=vulkan1.3 -fvk-use-scalar-layout

[[vk::binding(0,0)]] RWStructuredBuffer<uint32_t> buf;

typedef vk::SpirvType</*OpTypePointer*/32, /*size*/8, /*alignment*/8,
                      vk::Literal<vk::integral_constant<uint32_t, /*PhysicalStorageBuffer*/5349> >, uint32_t> PhysicalUintPtr;

struct PushData
{
    uint32_t        a;
    PhysicalUintPtr p;
};
[[vk::push_constant]] PushData pc;

[[vk::ext_capability(/*PhysicalStorageBufferAddresses*/5347)]]
[numthreads(64,1,1)]
void main(uint32_t gi : SV_GroupIndex)
{
    buf[gi] = pc.a;
}

Expected: compiles; p at Offset 8, OpMemoryModel PhysicalStorageBuffer64.
Actual: Program terminated with signal SIGSEGV (11) Compiler returned: 139.

Dominant language
C++
Stars
3.7k
Forks
926
Avg merge
3d 22h
Merged PRs (30d)
45

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/DirectXShaderCompiler

All issues in microsoft/DirectXShaderCompiler

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.