llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.47k forks source link

clang::Sema::SubstType asserts on CodeSynthesisContexts.empty(). #35146

Closed llvmbot closed 5 years ago

llvmbot commented 6 years ago
Bugzilla Link 35798
Resolution INVALID
Resolved on Apr 27, 2019 13:42
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

Related: llvm/llvm-project#35143 and llvm/llvm-project#35144 Came from the same original source but CReduce script was not sophisticated enough, and this bug was found.

Assertion says: "Cannot perform an instantiation without some context on the instantiation stack"

clang-6.0: /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:1565: clang::TypeSourceInfo clang::Sema::SubstType(clang::TypeSourceInfo , const clang::MultiLevelTemplateArgumentList &, clang::SourceLocation, clang::DeclarationName, bool): Assertion `!CodeSynthesisContexts.empty() && "Cannot perform an instantiation without some context on the " "instantiation stack"' failed.

​0 0x00000000064469c9 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /lhome/siedenc/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:398:11

​1 0x0000000006446b79 PrintStackTraceSignalHandler(void*) /lhome/siedenc/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:462:1

​2 0x0000000006445133 llvm::sys::RunSignalHandlers() /lhome/siedenc/src/llvm-project/llvm/lib/Support/Signals.cpp:0:5

​3 0x0000000006446ed4 SignalHandler(int) /lhome/siedenc/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:252:1

​4 0x00007f8e5728d330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)

​5 0x00007f8e55e7cc37 gsignal /build/eglibc-SvCtMH/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0

​6 0x00007f8e55e80028 abort /build/eglibc-SvCtMH/eglibc-2.19/stdlib/abort.c:91:0

​7 0x00007f8e55e75bf6 __assert_fail_base /build/eglibc-SvCtMH/eglibc-2.19/assert/assert.c:92:0

​8 0x00007f8e55e75ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)

​9 0x00000000093d1d1f clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, bool) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:1567:8

​10 0x0000000009435acf clang::TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(clang::NonTypeTemplateParmDecl*) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:2274:8

​11 0x000000000941c020 clang::declvisitor::Base<clang::declvisitor::make_ptr, clang::TemplateDeclInstantiator, clang::Decl>::Visit(clang::Decl) /lhome/siedenc/builds/llvm/tools/clang/include/clang/AST/DeclNodes.inc:435:1

​12 0x0000000009439c86 clang::Sema::SubstDecl(clang::Decl, clang::DeclContext, clang::MultiLevelTemplateArgumentList const&) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:3112:3

​13 0x00000000092c9013 clang::NonTypeTemplateParmDecl (anonymous namespace)::ConvertConstructorToDeductionGuideTransform::transformTemplateParameterImpl(clang::NonTypeTemplateParmDecl, clang::MultiLevelTemplateArgumentList&) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaTemplate.cpp:1714:9

​14 0x00000000092c860f (anonymous namespace)::ConvertConstructorToDeductionGuideTransform::transformTemplateParameter(clang::NamedDecl*, clang::MultiLevelTemplateArgumentList&) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaTemplate.cpp:1704:5

​15 0x00000000092a83af (anonymous namespace)::ConvertConstructorToDeductionGuideTransform::transformConstructor(clang::FunctionTemplateDecl, clang::CXXConstructorDecl) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaTemplate.cpp:1605:20

​16 0x00000000092a7ff3 clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*, clang::SourceLocation) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaTemplate.cpp:1909:14

​17 0x00000000090a7a0e DeclareImplicitMemberFunctionsWithName(clang::Sema&, clang::DeclarationName, clang::SourceLocation, clang::DeclContext const*) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaLookup.cpp:825:5

​18 0x00000000090ab523 LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaLookup.cpp:843:35

​19 0x00000000090a8022 CppNamespaceLookup(clang::Sema&, clang::LookupResult&, clang::ASTContext&, clang::DeclContext*, (anonymous namespace)::UnqualUsingDirectiveSet&) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaLookup.cpp:942:8

​20 0x00000000090a757d clang::Sema::CppLookupName(clang::LookupResult&, clang::Scope*) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaLookup.cpp:1322:15

​21 0x00000000090ab128 clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaLookup.cpp:1827:9

​22 0x0000000008adfdf2 clang::Sema::HandleDeclarator(clang::Scope, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList>) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaDecl.cpp:5393:3

​23 0x0000000008adf502 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) /lhome/siedenc/src/llvm-project/clang/lib/Sema/SemaDecl.cpp:5145:9

​24 0x000000000858d47d clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /lhome/siedenc/src/llvm-project/clang/lib/Parse/ParseDecl.cpp:2209:18

​25 0x000000000858e267 clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&) /lhome/siedenc/src/llvm-project/clang/lib/Parse/ParseDecl.cpp:2137:3

​26 0x0000000008622ca3 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) /lhome/siedenc/src/llvm-project/clang/lib/Parse/ParseTemplate.cpp:307:20

​27 0x0000000008621927 clang::Parser::ParseExplicitInstantiation(clang::DeclaratorContext, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation&, clang::AccessSpecifier) /lhome/siedenc/src/llvm-project/clang/lib/Parse/ParseTemplate.cpp:1310:10

​28 0x0000000008621827 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) /lhome/siedenc/src/llvm-project/clang/lib/Parse/ParseTemplate.cpp:34:5

​29 0x000000000858712f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) /lhome/siedenc/src/llvm-project/clang/lib/Parse/ParseDecl.cpp:1669:16

​30 0x0000000008521c53 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /lhome/siedenc/src/llvm-project/clang/lib/Parse/Parser.cpp:786:14

​31 0x0000000008520eb6 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&) /lhome/siedenc/src/llvm-project/clang/lib/Parse/Parser.cpp:609:12

​32 0x000000000851be4f clang::ParseAST(clang::Sema&, bool, bool) /lhome/siedenc/src/llvm-project/clang/lib/Parse/ParseAST.cpp:147:14

​33 0x0000000007023bfa clang::ASTFrontendAction::ExecuteAction() /lhome/siedenc/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1000:1

​34 0x00000000071b7f93 clang::CodeGenAction::ExecuteAction() /lhome/siedenc/src/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1032:1

​35 0x0000000007023690 clang::FrontendAction::Execute() /lhome/siedenc/src/llvm-project/clang/lib/Frontend/FrontendAction.cpp:901:7

​36 0x0000000006f378f2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /lhome/siedenc/src/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:992:7

​37 0x00000000071a1ecf clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /lhome/siedenc/src/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:252:8

​38 0x0000000003d98369 cc1_main(llvm::ArrayRef<char const>, char const, void*) /lhome/siedenc/src/llvm-project/clang/tools/driver/cc1_main.cpp:221:11

​39 0x0000000003d8b509 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /lhome/siedenc/src/llvm-project/clang/tools/driver/driver.cpp:309:5

​40 0x0000000003d8a20d main /lhome/siedenc/src/llvm-project/clang/tools/driver/driver.cpp:388:5

​41 0x00007f8e55e67f45 __libc_start_main /build/eglibc-SvCtMH/eglibc-2.19/csu/libc-start.c:321:0

​42 0x0000000003d89029 _start (/lhome/siedenc/builds/llvm/bin/clang-6.0+0x3d89029)

Stack dump:

  1. Program arguments: /lhome/siedenc/builds/llvm/bin/clang-6.0 -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists -disable-free -main-file-name bug3.cc -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /lhome/siedenc/devel/clang-crash/bug3.gcno -resource-dir /lhome/siedenc/builds/llvm/lib/clang/6.0.0 -I/lhome/siedenc/devel/athena/devel/include -I/opt/ros/jade/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward -internal-isystem /usr/local/include -internal-isystem /lhome/siedenc/builds/llvm/lib/clang/6.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /lhome/siedenc/devel/clang-crash -ferror-limit 19 -fmessage-length 241 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o bug3.bc -x c++ bug3.cc
  2. parser at end of file clang-6.0: error: unable to execute command: Aborted clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 6.0.0 Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /lhome/siedenc/builds/llvm/bin clang-6.0: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script. clang-6.0: note: diagnostic msg: ********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-6.0: note: diagnostic msg: /tmp/zsh-28636/bug3-a2dc27.cpp clang-6.0: note: diagnostic msg: /tmp/zsh-28636/bug3-a2dc27.sh clang-6.0: note: diagnostic msg:


llvmbot commented 5 years ago

Cannot reproduce this anymore.