microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
3.04k stars 677 forks source link

Compiler crash with raytracing payload qualifiers enabled #4920

Closed dmpots closed 3 weeks ago

dmpots commented 1 year ago

The following shader causes the compiler to crash with an access violation

// dxc /Tlib_6_6 rtpq.hlsl -enable-payload-qualifiers
[shader("raygeneration")]
void RayGen()
{
    if(true) {}
}

Removing the payload-qualifiers flag or the if(true) gets rid of the crash.

Keenuts commented 1 year ago

Hi! Thanks for the report!

Was able to reproduce at head (57512154fa3e48133f667f022528bce16251bc72) with the given command and shader (./build/bin/dxc -enable-payload-qualifiers -Tlib_6_6 repro.hlsl).

backtrace:

* thread #1, name = 'dxc', stop reason = signal SIGSEGV: invalid address (fault address: 0x50)
  * frame #0: 0x00007ffff5807cac libdxcompiler.so.3.7`clang::BumpVector<clang::CFGBlock::AdjacentBlock>::begin(this=0x0000000000000050) at BumpVector.h:84:29
    frame #1: 0x00007ffff58079a9 libdxcompiler.so.3.7`clang::CFGBlock::succ_begin(this=0x0000000000000000) at CFG.h:542:67
    frame #2: 0x00007ffff58fcf15 libdxcompiler.so.3.7`llvm::GraphTraits<clang::CFGBlock*>::child_begin(N=0x0000000000000000) at CFG.h:1010:15
    frame #3: 0x00007ffff590091e libdxcompiler.so.3.7`unsigned int llvm::DFSPass<llvm::GraphTraits<clang::CFGBlock*> >(DT=0x0000555555ada3d0, V=0x0000555555adaf68, N=4) at GenericDomTreeConstruction.h:99:47
    frame #4: 0x00007ffff58fc1fc libdxcompiler.so.3.7`void llvm::Calculate<clang::CFG, clang::CFGBlock*>(DT=0x0000555555ada3d0, F=0x0000555555a82260) at GenericDomTreeConstruction.h:170:9
    frame #5: 0x00007ffff58fbdcd libdxcompiler.so.3.7`void llvm::DominatorTreeBase<clang::CFGBlock>::recalculate<clang::CFG>(this=0x0000555555ada3d0, F=0x0000555555a82260) at GenericDomTree.h:729:7
    frame #6: 0x00007ffff58fa249 libdxcompiler.so.3.7`clang::DominatorTree::buildDominatorTree(this=0x00007fffffff8498, AC=0x0000555555adaaa0) at Dominators.h:85:9
    frame #7: 0x00007ffff58e08ea libdxcompiler.so.3.7`(anonymous namespace)::DiagnosePayloadAccess(S=0x0000555555a8b650, Info=0x00007fffffff8690, FieldsToIgnoreRead=size=0, FieldsToIgnoreWrite=size=0, VisitedFunctions=size=0)::DxrShaderDiagnoseInfo&, std::set<clang::FieldDecl const*, std::less<clang::FieldDecl const*>, std::allocator<clang::FieldDecl const*> > const&, std::set<clang::FieldDecl const*, std::less<clang::FieldDecl const*>, std::allocator<clang::FieldDecl const*> > const&, std::set<clang::FunctionDecl const*, std::less<clang::FunctionDecl const*>, std::allocator<clang::FunctionDecl const*> >) at SemaDXR.cpp:952:6
    frame #8: 0x00007ffff58e04eb libdxcompiler.so.3.7`(anonymous namespace)::DXRShaderVisitor::VisitFunctionDecl(this=0x00007fffffff89e0, Decl=0x0000555555ac2120) at SemaDXR.cpp:1122:7
    frame #9: 0x00007ffff58dfd1d libdxcompiler.so.3.7`clang::RecursiveASTVisitor<(anonymous namespace)::DXRShaderVisitor>::WalkUpFromFunctionDecl(this=0x00007fffffff89e0, D=0x0000555555ac2120) at DeclNodes.inc:363:1
    frame #10: 0x00007ffff58a19bd libdxcompiler.so.3.7`clang::RecursiveASTVisitor<(anonymous namespace)::DXRShaderVisitor>::TraverseFunctionDecl(this=0x00007fffffff89e0, D=0x0000555555ac2120) at RecursiveASTVisitor.h:1832:1
    frame #11: 0x00007ffff589e686 libdxcompiler.so.3.7`clang::RecursiveASTVisitor<(anonymous namespace)::DXRShaderVisitor>::TraverseDecl(this=0x00007fffffff89e0, D=0x0000555555ac2120) at DeclNodes.inc:363:1
    frame #12: 0x00007ffff589dd92 libdxcompiler.so.3.7`clang::RecursiveASTVisitor<(anonymous namespace)::DXRShaderVisitor>::TraverseDeclContextHelper(this=0x00007fffffff89e0, DC=0x0000555555a81530) at RecursiveASTVisitor.h:1267:7
    frame #13: 0x00007ffff589dbda libdxcompiler.so.3.7`clang::RecursiveASTVisitor<(anonymous namespace)::DXRShaderVisitor>::TraverseTranslationUnitDecl(this=0x00007fffffff89e0, D=0x0000555555a81510) at RecursiveASTVisitor.h:1359:1
    frame #14: 0x00007ffff589db5d libdxcompiler.so.3.7`(anonymous namespace)::DXRShaderVisitor::diagnose(this=0x00007fffffff89e0, TU=0x0000555555a81510) at SemaDXR.cpp:1090:44
    frame #15: 0x00007ffff589dafb libdxcompiler.so.3.7`hlsl::DiagnoseRaytracingPayloadAccess(S=0x0000555555a8b650, TU=0x0000555555a81510) at SemaDXR.cpp:1137:11
    frame #16: 0x00007ffff53a8da2 libdxcompiler.so.3.7`hlsl::DiagnoseTranslationUnit(self=0x0000555555a8b650) at SemaHLSL.cpp:10701:7
    frame #17: 0x00007ffff61f00ca libdxcompiler.so.3.7`clang::ParseAST(S=0x0000555555a8b650, PrintStats=false, SkipFunctionBodies=false) at ParseAST.cpp:162:3
    frame #18: 0x00007ffff4e4b9ec libdxcompiler.so.3.7`clang::ASTFrontendAction::ExecuteAction(this=0x00007fffffffaec8) at FrontendAction.cpp:554:3
    frame #19: 0x00007ffff4a4026e libdxcompiler.so.3.7`clang::CodeGenAction::ExecuteAction(this=0x00007fffffffaec8) at CodeGenAction.cpp:807:28
    frame #20: 0x00007ffff4e4b499 libdxcompiler.so.3.7`clang::FrontendAction::Execute(this=0x00007fffffffaec8) at FrontendAction.cpp:455:8
    frame #21: 0x00007ffff3fe6924 libdxcompiler.so.3.7`DxcCompiler::Compile(this=0x0000555555a2eb30, pSource=0x00007fffffffc2f0, pArguments=0x0000555555a2ea20, argCount=6, pIncludeHandler=0x0000555555a2ef70, riid=0x000055555591d6a8, ppResult=0x00007fffffffc288) at dxcompilerobj.cpp:1051:18
    frame #22: 0x00007ffff3fda017 libdxcompiler.so.3.7`hlsl::DxcCompilerAdapter::WrapCompile(this=0x0000555555a2ef50, bPreprocess=NO, pSource=0x0000555555a2f000, pSourceName=L"repro.hlsl", pEntryPoint=L"lib.no::entry", pTargetProfile=L"lib_6_6", pArguments=0x0000555555a2ea00, argCount=3, pDefines=0x00007fffffffd970, defineCount=0, pIncludeHandler=0x0000555555a2ef70, ppResult=0x00007fffffffd370, ppDebugBlobName=0x0000000000000000, ppDebugBlob=0x0000000000000000) at dxcompilerobj.cpp:1827:5
    frame #23: 0x00007ffff3fdb60c libdxcompiler.so.3.7`hlsl::DxcCompilerAdapter::CompileWithDebug(this=0x0000555555a2ef50, pSource=0x0000555555a2f000, pSourceName=L"repro.hlsl", pEntryPoint=L"lib.no::entry", pTargetProfile=L"lib_6_6", pArguments=0x0000555555a2ea00, argCount=3, pDefines=0x00007fffffffd970, defineCount=0, pIncludeHandler=0x0000555555a2ef70, ppResult=0x00007fffffffd370, ppDebugBlobName=0x0000000000000000, ppDebugBlob=0x0000000000000000) at dxcompilerobj.cpp:1731:10
    frame #24: 0x00007ffff3fe07d6 libdxcompiler.so.3.7`hlsl::DxcCompilerAdapter::Compile(this=0x0000555555a2ef50, pSource=0x0000555555a2f000, pSourceName=L"repro.hlsl", pEntryPoint=L"lib.no::entry", pTargetProfile=L"lib_6_6", pArguments=0x0000555555a2ea00, argCount=3, pDefines=0x00007fffffffd970, defineCount=0, pIncludeHandler=0x0000555555a2ef70, ppResult=0x00007fffffffd370) at dxcompileradapter.h:69:12
    frame #25: 0x000055555565d993 dxc`DxcContext::Compile(this=0x00007fffffffd6e8) at dxc.cpp:841:9
    frame #26: 0x0000555555661f74 dxc`dxc::main(argc=4, argv_=0x00007fffffffe3d8) at dxc.cpp:1448:24
    frame #27: 0x00005555555bc422 dxc`main(argc=4, argv_=0x00007fffffffe3d8) at dxcmain.cpp:20:12
    frame #28: 0x00007ffff383c290 libc.so.6`___lldb_unnamed_symbol3141 + 128
    frame #29: 0x00007ffff383c34a libc.so.6`__libc_start_main + 138
    frame #30: 0x00005555555bc325 dxc`_start at start.S:115
pow2clk commented 3 weeks ago

https://godbolt.org/z/Ej5KKMnWx

fixed!