microsoft / microsoft/DirectXShaderCompiler

Using large vert/hull/domain IO makes DXC crash when building to DXIL

Open
#6,016 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug crash diagnostic incorrect-code
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description

The issue was originally only on the SPIR-V backend (#3735), but while fixing it for SPIR-V, noticed DXIL is now also broken.

Steps to Reproduce

https://godbolt.org/z/T9c5Tdnsf

struct ControlPoint {
  float4 position[100] : POSITION;
};

struct HullPatchOut {
    float edge [3] : SV_TessFactor;
    float inside : SV_InsideTessFactor;
};

HullPatchOut HullConst () {
  return (HullPatchOut)0;
}

[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]
[patchconstantfunc("HullConst")]
[outputcontrolpoints(3)]
ControlPoint Hull(InputPatch<ControlPoint, 1> v,
                  uint id : SV_OutputControlPointID) {
  ControlPoint p;
  return p;
}

Actual Behavior

[user@hostname DirectXShaderCompiler]$ dxc -T hs_6_0 -E Hull repro.hlsl
Failed to allocate all input signature elements in available space.
UNREACHABLE executed at DirectXShaderCompiler/lib/HLSL/HLSignatureLower.cpp:523!
Aborted

Backtrace:

 thread #1, name = 'dxc', stop reason = signal SIGABRT
  * frame #0: 0x00007ffff3ca80fc libc.so.6`__pthread_kill_implementation(threadid=<unavailable>, signo=6, no_tid=<unavailable>) at pthread_kill.c:44:76
    frame #1: 0x00007ffff3c5a472 libc.so.6`__GI_raise(sig=6) at raise.c:26:13
    frame #2: 0x00007ffff3c444b2 libc.so.6`__GI_abort at abort.c:79:7
    frame #3: 0x00007ffff4c8dd8a libdxcompiler.so`llvm::llvm_unreachable_internal(msg="Failed to allocate all input signature elements in available space.", file="DirectXShaderCompiler/lib/HLSL/HLSignatureLower.cpp", line=523) at ErrorHandling.cpp:137:3
    frame #4: 0x00007ffff49449e7 libdxcompiler.so`hlsl::HLSignatureLower::AllocateDxilInputOutputs(this=0x00007fffffff79b0) at HLSignatureLower.cpp:522:5
    frame #5: 0x00007ffff494c834 libdxcompiler.so`hlsl::HLSignatureLower::Run(this=0x00007fffffff79b0) at HLSignatureLower.cpp:1797:5
    frame #6: 0x00007ffff48ccb62 libdxcompiler.so`(anonymous namespace)::DxilGenerationPass::runOnModule(this=0x0000555555ab7490, M=0x0000555555a32490) at DxilGenerationPass.cpp:223:16
    frame #7: 0x00007ffff67e83dd libdxcompiler.so`(anonymous namespace)::MPPassManager::runOnModule(this=0x0000555555a260f0, M=0x0000555555a32490) at LegacyPassManager.cpp:1669:27
    frame #8: 0x00007ffff67e7e86 libdxcompiler.so`llvm::legacy::PassManagerImpl::run(this=0x0000555555aa7160, M=0x0000555555a32490) at LegacyPassManager.cpp:1771:44
    frame #9: 0x00007ffff67e8a94 libdxcompiler.so`llvm::legacy::PassManager::run(this=0x0000555555aa70d0, M=0x0000555555a32490) at LegacyPassManager.cpp:1814:14
    frame #10: 0x00007ffff4dcddec libdxcompiler.so`(anonymous namespace)::EmitAssemblyHelper::EmitAssembly(this=0x00007fffffff8248, Action=Backend_EmitBC, OS=0x0000555555a319f0) at BackendUtil.cpp:756:22
    frame #11: 0x00007ffff4dcd14e libdxcompiler.so`clang::EmitBackendOutput(Diags=0x00005555559f59a0, CGOpts=0x00005555559f44c0, TOpts=0x00005555559f5080, LOpts=0x00005555559f4f10, TDesc=(Data = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64", Length = 79), M=0x0000555555a32490, Action=Backend_EmitBC, OS=0x0000555555a319f0) at BackendUtil.cpp:779:15
    frame #12: 0x00007ffff4da4bf9 libdxcompiler.so`clang::BackendConsumer::HandleTranslationUnit(this=0x0000555555a31ae0, C=0x0000555555a1bc60) at CodeGenAction.cpp:191:7
    frame #13: 0x00007ffff6393392 libdxcompiler.so`clang::ParseAST(S=0x0000555555a327b0, PrintStats=false, SkipFunctionBodies=false) at ParseAST.cpp:164:13
    frame #14: 0x00007ffff515dc9c libdxcompiler.so`clang::ASTFrontendAction::ExecuteAction(this=0x00007fffffff9c20) at FrontendAction.cpp:554:3
    frame #15: 0x00007ffff4da30c2 libdxcompiler.so`clang::CodeGenAction::ExecuteAction(this=0x00007fffffff9c20) at CodeGenAction.cpp:807:28
    frame #16: 0x00007ffff515d78c libdxcompiler.so`clang::FrontendAction::Execute(this=0x00007fffffff9c20) at FrontendAction.cpp:455:8
    frame #17: 0x00007ffff43f05c6 libdxcompiler.so`DxcCompiler::Compile(this=0x00005555559f19e0, pSource=0x00007fffffffc270, pArguments=0x00005555559f1930, argCount=5, pIncludeHandler=0x00005555559f16c0, riid=0x00005555558aecc0, ppResult=0x00007fffffffb7b8) at dxcompilerobj.cpp:972:18
    frame #18: 0x00007ffff43e4d47 libdxcompiler.so`hlsl::DxcCompilerAdapter::WrapCompile(this=0x00005555559f1e00, bPreprocess=NO, pSource=0x00005555559f1e90, pSourceName=L"repro.hlsl", pEntryPoint=L"Hull", pTargetProfile=L"hs_6_0", pArguments=0x00005555559f1980, argCount=4, pDefines=0x00007fffffffced8, defineCount=0, pIncludeHandler=0x00005555559f16c0, ppResult=0x00007fffffffca70, ppDebugBlobName=0x0000000000000000, ppDebugBlob=0x0000000000000000) at dxcompilerobj.cpp:1820:5
    frame #19: 0x00007ffff43e624c libdxcompiler.so`hlsl::DxcCompilerAdapter::CompileWithDebug(this=0x00005555559f1e00, pSource=0x00005555559f1e90, pSourceName=L"repro.hlsl", pEntryPoint=L"Hull", pTargetProfile=L"hs_6_0", pArguments=0x00005555559f1980, argCount=4, pDefines=0x00007fffffffced8, defineCount=0, pIncludeHandler=0x00005555559f16c0, ppResult=0x00007fffffffca70, ppDebugBlobName=0x0000000000000000, ppDebugBlob=0x0000000000000000) at dxcompilerobj.cpp:1723:10
    frame #20: 0x00007ffff43ea3b6 libdxcompiler.so`hlsl::DxcCompilerAdapter::Compile(this=0x00005555559f1e00, pSource=0x00005555559f1e90, pSourceName=L"repro.hlsl", pEntryPoint=L"Hull", pTargetProfile=L"hs_6_0", pArguments=0x00005555559f1980, argCount=4, pDefines=0x00007fffffffced8, defineCount=0, pIncludeHandler=0x00005555559f16c0, ppResult=0x00007fffffffca70) at dxcompileradapter.h:75:12
    frame #21: 0x00005555555c5ccc dxc`DxcContext::Compile(this=0x00007fffffffcd38) at dxc.cpp:873:9
    frame #22: 0x00005555555c9ee1 dxc`dxc::main(argc=6, argv_=0x00007fffffffd9c8) at dxc.cpp:1501:24
    frame #23: 0x00005555555be512 dxc`main(argc=6, argv_=0x00007fffffffd9c8) at dxcmain.cpp:19:10
    frame #24: 0x00007ffff3c456ca libc.so.6`__libc_start_call_main(main=(dxc`main at dxcmain.cpp:18), argc=6, argv=0x00007fffffffd9c8) at libc_start_call_main.h:58:16
    frame #25: 0x00007ffff3c45785 libc.so.6`__libc_start_main_impl(main=(dxc`main at dxcmain.cpp:18), argc=6, argv=0x00007fffffffd9c8, init=0x00007ffff7ffd000, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffd9b8) at libc-start.c:360:3
    frame #26: 0x00005555555be421 dxc`_start + 33

Environment

  • DXC version HEAD (bdd7d9b0b9e8bfd28d6f25e8287f4a5fcd0d864c)
  • Host Operating System: Linux

Contributor guide

Open the contributing guide

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.

Research direction

Start with the HLSL input-signature allocation path in lib/HLSL/HLSignatureLower.cpp, especially AllocateDxilInputOutputs around line 523. Reproduce the failure with the linked Godbolt example or the dxc hs_6_0 command and inspect the reported assertion. Done means the large hull/domain input compiles without crashing and preserves the expected diagnostic or output behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.