[SPIR-V] We cannot debug our shaders because `-fspv-debug=vulkan` asserts “isa<> used on a null pointer” on void template arguments and vk::SpirvType variables
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start in tools/clang/lib/SPIRV/DebugTypeVisitor.cpp, especially lowerToDebugType, lowerDebugTypeTemplate, and lowerToDebugTypeComposite, as named in the report. Reproduce with either shader and the supplied dxc arguments, then trace how void template arguments and vk::SpirvType values are lowered. Done means both patterns compile with SPIR-V debug info and no assertion.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
Compiling either of the two shaders below with -fspv-debug=vulkan-with-source (or plain -fspv-debug=vulkan) makes dxc exit without producing any output or diagnostic. Release builds terminate with exit code 0xE0000001 (STATUS_LLVM_ASSERT) and print nothing. -Od makes no difference. Without the -fspv-debug option both shaders compile and validate fine.
Steps to Reproduce
Compiler arguments for both files:
-T cs_6_8 -E main -spirv -fspv-target-env=vulkan1.3 -HV 202x -fspv-debug=vulkan-with-source
Repro A: struct template with a void type argument
https://godbolt.org/z/WEMWje6rP
template<typename T, typename Unused = void>
struct Plus
{
static const T identity = T(0);
T operator()(const in T a, const in T b) { return a + b; }
};
[[vk::binding(0,0)]] RWStructuredBuffer<uint> buff;
[numthreads(64,1,1)]
void main(uint3 ID : SV_DispatchThreadID) { Plus<uint> op; buff[ID.x] = op(buff[ID.x], Plus<uint>::identity); }
Repro B: vk::SpirvType as a struct member
https://godbolt.org/z/E8jGnxKGK
using bda_ptr_t = vk::SpirvType</*OpTypePointer*/32, 8, 8, vk::Literal<vk::integral_constant<uint, /*PhysicalStorageBuffer*/5349> >, uint>;
[[vk::ext_capability(/*PhysicalStorageBufferAddresses*/5347)]]
[[vk::ext_instruction(/*OpBitcast*/124)]]
bda_ptr_t toPtr(uint64_t addr);
[[vk::ext_instruction(/*OpLoad*/61)]]
uint loadPtr(bda_ptr_t p, [[vk::ext_literal]] uint aligned, [[vk::ext_literal]] uint alignment);
struct Ref { bda_ptr_t ptr; uint load() { return loadPtr(ptr, 2, 4); } };
struct PC { uint64_t addr; };
[[vk::push_constant]] PC pc;
[[vk::binding(0,0)]] RWStructuredBuffer<uint> buff;
[numthreads(64,1,1)]
void main(uint3 ID : SV_DispatchThreadID)
{
Ref r; r.ptr = toPtr(pc.addr + ID.x * 4);
buff[ID.x] = r.load();
}
The same bda_ptr_t as a local variable or as a parameter of a non-intrinsic function crashes too.
Actual Behavior
dxc exits with code 0xE0000001 and no output. Running it under a debugger shows this assertion, which is otherwise only sent to OutputDebugString:
Error: assert(Val && "isa<> used on a null pointer")
File: include/llvm/Support/Casting.h(96)
Func: llvm::isa_impl_cl<clang::spirv::SpirvDebugType, const clang::spirv::SpirvDebugType*>::doit
Expected Behavior
Valid SPIR-V with debug info. Both patterns are common and used a lot in Nabla: the void default argument is the usual SFINAE idiom, and vk::SpirvType members are how buffer-device-address pointers get wrapped in user code.
Environment
- DXC version godbolt trunk
Possible cause
I have not debugged this properly, but from reading tools/clang/lib/SPIRV/DebugTypeVisitor.cpp it looks like DebugTypeVisitor::lowerToDebugType has no case for SpirvType::TK_Void or SpirvType::TK_SpirvIntrinsicType, so it returns nullptr (after queueing a "Fail to lower SpirvType" diagnostic that never gets printed). The callers seem to use that result unchecked: the template-parameter path in lowerDebugTypeTemplate, the member path in lowerToDebugTypeComposite, and the function-type case. If that is right, lowering those kinds to a DebugTypeBasic with the Unspecified encoding (or DebugInfoNone, which NonSemantic.Shader.DebugInfo.100 allows wherever a type is expected) and skipping members or template parameters
- Lingua principale
- C++
- Stelle
- 3.7k
- Fork
- 926
- Merge medio
- 3g 22h
- PR unite (30g)
- 45
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/DirectXShaderCompiler
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/DirectXShaderCompiler#9173 ·
I maintainer di solito rispondono entro 2 giorni
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
microsoft/DirectXShaderCompiler#9155 · 4 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/DirectXShaderCompiler#9135 ·
I maintainer di solito rispondono entro 2 giorni
-
DXC emits DW_LANG_C_plus_plus instead of DW_LANG_HLSL for HLSLForse già presa @rj123-nv l’ha presa 18 giorni fa. Apertabug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
microsoft/DirectXShaderCompiler#9087 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
microsoft/DirectXShaderCompiler#9086 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di microsoft/DirectXShaderCompiler
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
feature:config kind:docs os:windows toolchain:cmake triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
arch-based bug niri
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
noctalia-dev/noctalia#5552 ·
I maintainer di solito rispondono entro 1 giorno