DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Access violation on variable with initializer if type is qualified

Open siliconvoodoo opened this issue 3 years ago • 1 comments

code:

class B
{
    int b;
};

static ::B b = {0};

Effect: image

siliconvoodoo avatar Aug 30 '22 11:08 siliconvoodoo

Thanks for the report 🙂

Steps to reproduce:

./dxc -T cs_6_0 repro.hlsl

With the content of the given code in repro.hlsl. Without the full qualification, the compilation fails due to a missing entry point definition (expected). With full qualification, segfault.

Backtrace:

#0  clang::TagType::getDecl (this=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/AST/Type.cpp:2920
#1  0x00007ffff4f95565 in clang::RecordType::getDecl (this=0x0) at ~/DirectXShaderCompiler/tools/clang/include/clang/AST/Type.h:3562
#2  0x00007ffff57eea16 in FlattenedTypeIterator::pushTrackerForType (this=0x7fffffff5060, type=..., expression=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/Sema/SemaHLSL.cpp:11550
#3  0x00007ffff57ee6bd in FlattenedTypeIterator::FlattenedTypeIterator (this=0x7fffffff5060, loc=..., type=..., source=...) at ~/DirectXShaderCompiler/tools/clang/lib/Sema/SemaHLSL.cpp:11264
#4  0x00007ffff57e0974 in FlattenedTypeIterator::CompareTypesForInit (source=..., left=..., args=..., leftLoc=..., rightLoc=...) at ~/DirectXShaderCompiler/tools/clang/lib/Sema/SemaHLSL.cpp:11710
#5  0x00007ffff57e026d in HLSLExternalSource::InitializeInitSequenceForHLSL (this=0x5555558c7f00, Entity=..., Kind=..., Args=..., TopLevelOfInitList=0x0, initSequence=0x7fffffff60b8) at ~/DirectXShaderCompiler/tools/clang/lib/Sema/SemaHLSL.cpp:7623
#6  0x00007ffff57edc0d in hlsl::InitializeInitSequenceForHLSL (self=0x5555558d0ea0, Entity=..., Kind=..., Args=..., TopLevelOfInitList=0x0, initSequence=0x7fffffff60b8) at ~/DirectXShaderCompiler/tools/clang/lib/Sema/SemaHLSL.cpp:11044
#7  0x00007ffff586b82f in clang::InitializationSequence::InitializeFrom (this=0x7fffffff60b8, S=..., Entity=..., Kind=..., Args=..., TopLevelOfInitList=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/Sema/SemaInit.cpp:4875
#8  0x00007ffff586b47d in clang::InitializationSequence::InitializationSequence (this=0x7fffffff60b8, S=..., Entity=..., Kind=..., Args=..., TopLevelOfInitList=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/Sema/SemaInit.cpp:4816
#9  0x00007ffff54a2bf5 in clang::Sema::AddInitializerToDecl (this=0x5555558d0ea0, RealDecl=0x555555907a10, Init=0x555555907ae0, DirectInit=0x0, TypeMayContainAuto=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/Sema/SemaDecl.cpp:9200
#10 0x00007ffff6532234 in clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes (this=0x5555558d3ac0, D=..., TemplateInfo=..., FRI=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/Parse/ParseDecl.cpp:2714
#11 0x00007ffff65308e5 in clang::Parser::ParseDeclGroup (this=0x5555558d3ac0, DS=..., Context=0x0, DeclEnd=0x0, FRI=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/Parse/ParseDecl.cpp:2458
#12 0x00007ffff650a51c in clang::Parser::ParseDeclOrFunctionDefInternal (this=0x5555558d3ac0, attrs=..., DS=..., AS=clang::AS_none) at ~/DirectXShaderCompiler/tools/clang/lib/Parse/Parser.cpp:965
#13 0x00007ffff6509ca5 in clang::Parser::ParseDeclarationOrFunctionDefinition (this=0x5555558d3ac0, attrs=..., DS=0x0, AS=clang::AS_none) at ~/DirectXShaderCompiler/tools/clang/lib/Parse/Parser.cpp:981
#14 0x00007ffff6509243 in clang::Parser::ParseExternalDeclaration (this=0x5555558d3ac0, attrs=..., DS=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/Parse/Parser.cpp:839
#15 0x00007ffff6507fb0 in clang::Parser::ParseTopLevelDecl (this=0x5555558d3ac0, Result=...) at ~/DirectXShaderCompiler/tools/clang/lib/Parse/Parser.cpp:606
#16 0x00007ffff6503603 in clang::ParseAST (S=..., PrintStats=0x0, SkipFunctionBodies=0x0) at ~/DirectXShaderCompiler/tools/clang/lib/Parse/ParseAST.cpp:146
#17 0x00007ffff5302c68 in clang::ASTFrontendAction::ExecuteAction (this=0x7fffffffa038) at ~/DirectXShaderCompiler/tools/clang/lib/Frontend/FrontendAction.cpp:554
#18 0x00007ffff4f53a42 in clang::CodeGenAction::ExecuteAction (this=0x7fffffffa038) at ~/DirectXShaderCompiler/tools/clang/lib/CodeGen/CodeGenAction.cpp:800
#19 0x00007ffff530274c in clang::FrontendAction::Execute (this=0x7fffffffa038) at ~/DirectXShaderCompiler/tools/clang/lib/Frontend/FrontendAction.cpp:455
#20 0x00007ffff463b0a8 in DxcCompiler::Compile (this=0x555555891d80, pSource=0x7fffffffc340, pArguments=0x5555558937a0, argCount=0x5, pIncludeHandler=0x555555891c90, riid=..., ppResult=0x7fffffffb908) at ~/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompilerobj.cpp:1042
#21 0x00007ffff462f120 in hlsl::DxcCompilerAdapter::WrapCompile (this=0x5555558921c8, bPreprocess=0x0, pSource=0x5555558922a0, pSourceName=0x555555892210 L"/tmp/repro.hlsl", pEntryPoint=0x5555558934b0 L"main", pTargetProfile=0x5555558934e0 L"cs_6_0", pArguments=0x555555891a80, argCount=0x2, pDefines=0x7fffffffcf28, defineCount=0x0, pIncludeHandler=0x555555891c90, ppResult=0x7fffffffcae0, ppDebugBlobName=0x0, ppDebugBlob=0x0) at ~/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompilerobj.cpp:1821
#22 0x00007ffff46302cc in hlsl::DxcCompilerAdapter::CompileWithDebug (this=0x5555558921c8, pSource=0x5555558922a0, pSourceName=0x555555892210 L"/tmp/repro.hlsl", pEntryPoint=0x5555558934b0 L"main", pTargetProfile=0x5555558934e0 L"cs_6_0", pArguments=0x555555891a80, argCount=0x2, pDefines=0x7fffffffcf28, defineCount=0x0, pIncludeHandler=0x555555891c90, ppResult=0x7fffffffcae0, ppDebugBlobName=0x0, ppDebugBlob=0x0) at ~/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompilerobj.cpp:1727
#23 0x00007ffff4635076 in hlsl::DxcCompilerAdapter::Compile (this=0x5555558921c8, pSource=0x5555558922a0, pSourceName=0x555555892210 L"/tmp/repro.hlsl", pEntryPoint=0x5555558934b0 L"main", pTargetProfile=0x5555558934e0 L"cs_6_0", pArguments=0x555555891a80, argCount=0x2, pDefines=0x7fffffffcf28, defineCount=0x0, pIncludeHandler=0x555555891c90, ppResult=0x7fffffffcae0) at ~/DirectXShaderCompiler/tools/clang/tools/dxcompiler/dxcompileradapter.h:69
#24 0x00005555555a39ad in DxcContext::Compile (this=0x7fffffffcd88) at ~/DirectXShaderCompiler/tools/clang/tools/dxclib/dxc.cpp:842
#25 0x00005555555a7951 in dxc::main (argc=0x4, argv_=0x7fffffffd978) at ~/DirectXShaderCompiler/tools/clang/tools/dxclib/dxc.cpp:1437
#26 0x000055555559ddf2 in main (argc=0x4, argv_=0x7fffffffd978) at ~/DirectXShaderCompiler/tools/clang/tools/dxc/dxcmain.cpp:20

Keenuts avatar Sep 12 '22 20:09 Keenuts