[llvm-bugs] [Bug 49669] New: Clang crush when trying to parse ambiguous template function

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 21 06:45:12 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49669

            Bug ID: 49669
           Summary: Clang crush when trying to parse ambiguous template
                    function
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: calebxyz at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 24670
  --> https://bugs.llvm.org/attachment.cgi?id=24670&action=edit
Small program that demonstrates the crash

Clang crashes on ambiguous template function instantiation

I'm attaching a short C++ program that demonstrates the problem. 

The crash happens with Clang 11, 11.1 and trunk 

clang 10.0.1 doesn't crash but the error message is weird 

clang 10 : 

#1 with x86-64 clang 10.0.1
<source>:85:47: error: type name requires a specifier or qualifier
    if (std::is_same_v<output_t::type, MyFLBA>){
                                              ^
<source>:85:47: error: expected unqualified-id
2 errors generated.
ASM generation compiler returned: 1
<source>:85:47: error: type name requires a specifier or qualifier
    if (std::is_same_v<output_t::type, MyFLBA>){
                                              ^
<source>:85:47: error: expected unqualified-id
2 errors generated.
Execution build compiler returned: 1


clang 11 crush report:

PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-11.0.1/bin/clang++ -g
-o ./output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-10.2.0 -fcolor-diagnostics
-fno-crash-diagnostics -O3 -std=c++20 <source> 
1.      <eof> parser at end of file
2.      <source>:81:5: LLVM IR generation of declaration 'main'
3.      <source>:81:5: Generating code for declaration 'main'
 #0 0x000055919fd1fc5a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2cacc5a)
 #1 0x000055919fd1da04 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2caaa04)
 #2 0x000055919fd1dc75 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2caac75)
 #3 0x000055919fc924a0 CrashRecoverySignalHandler(int)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2c1f4a0)
 #4 0x00007ff14fd9c3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #5 0x00005591a0243097 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot, bool)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x31d0097)
 #6 0x00005591a024a5a2
clang::CodeGen::CodeGenFunction::getOrCreateOpaqueRValueMapping(clang::OpaqueValueExpr
const*) (/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x31d75a2)
 #7 0x00005591a0289abc (anonymous
namespace)::ScalarExprEmitter::Visit(clang::Expr*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x3216abc)
 #8 0x00005591a0289dd3
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x3216dd3)
 #9 0x00005591a0248e3a
clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x31d5e3a)
#10 0x00005591a002fabc
clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*,
llvm::BasicBlock*, llvm::BasicBlock*, unsigned long)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2fbcabc)
#11 0x000055919ffe7e9a
clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2f74e9a)
#12 0x000055919ffe7239 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2f74239)
#13 0x000055919ffe76dc
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2f746dc)
#14 0x00005591a0030241
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2fbd241)
#15 0x00005591a00399fe
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2fc69fe)
#16 0x00005591a007979a
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x300679a)
#17 0x00005591a00776d5
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x30046d5)
#18 0x00005591a0077de3
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x3004de3)
#19 0x00005591a007d081
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.4910)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x300a081)
#20 0x00005591a0ae76b1 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x3a746b1)
#21 0x00005591a0ada5e6
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x3a675e6)
#22 0x00005591a1856eb4 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x47e3eb4)
#23 0x00005591a050b809 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x3498809)
#24 0x00005591a04c532b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x345232b)
#25 0x00005591a05d1e9b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x355ee9b)
#26 0x000055919def97ac cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-11.0.1/bin/clang+++0xe867ac)
#27 0x000055919def62ad ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0xe832ad)
#28 0x00005591a039d055 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x332a055)
#29 0x000055919fc92583
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x2c1f583)
#30 0x00005591a039db30
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.148)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x332ab30)
#31 0x00005591a0377d05
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x3304d05)
#32 0x00005591a037874f
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x330574f)
#33 0x00005591a03812e5
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0x330e2e5)
#34 0x000055919de36421 main
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0xdc3421)
#35 0x00007ff14f84d0b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#36 0x000055919def5e2a _start
(/opt/compiler-explorer/clang-11.0.1/bin/clang+++0xe82e2a)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
ASM generation compiler returned: 254
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-11.0.1/bin/clang-11
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name example.cpp
-mrelocation-model static -mframe-pointer=none -fmath-errno -fno-rounding-math
-mconstructor-aliases -munwind-tables -target-cpu x86-64
-fno-split-dwarf-inlining -debug-info-kind=limited -dwarf-version=4
-debugger-tuning=gdb -resource-dir
/opt/compiler-explorer/clang-11.0.1/lib/clang/11.0.1 -internal-isystem
/opt/compiler-explorer/gcc-10.2.0/lib/gcc/x86_64-linux-gnu/10.2.0/../../../../include/c++/10.2.0
-internal-isystem
/opt/compiler-explorer/gcc-10.2.0/lib/gcc/x86_64-linux-gnu/10.2.0/../../../../include/c++/10.2.0/x86_64-linux-gnu
-internal-isystem
/opt/compiler-explorer/gcc-10.2.0/lib/gcc/x86_64-linux-gnu/10.2.0/../../../../include/c++/10.2.0/backward
-internal-isystem /usr/local/include -internal-isystem
/opt/compiler-explorer/clang-11.0.1/lib/clang/11.0.1/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O3
-std=c++20 -fdeprecated-macro -fdebug-compilation-dir /home/ce -ferror-limit 19
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-vectorize-loops -vectorize-slp -faddrsig -o /tmp/example-fe3c8c.o -x c++
<source> 
1.      <eof> parser at end of file
2.      <source>:81:5: LLVM IR generation of declaration 'main'
3.      <source>:81:5: Generating code for declaration 'main'
 #0 0x0000563c387c1c5a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2cacc5a)
 #1 0x0000563c387bfa04 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2caaa04)
 #2 0x0000563c387bfb53 SignalHandler(int)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2caab53)
 #3 0x00007f0f16d5c3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x0000563c38ce5097 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot, bool)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x31d0097)
 #5 0x0000563c38cec5a2
clang::CodeGen::CodeGenFunction::getOrCreateOpaqueRValueMapping(clang::OpaqueValueExpr
const*) (/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x31d75a2)
 #6 0x0000563c38d2babc (anonymous
namespace)::ScalarExprEmitter::Visit(clang::Expr*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x3216abc)
 #7 0x0000563c38d2bdd3
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x3216dd3)
 #8 0x0000563c38ceae3a
clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x31d5e3a)
 #9 0x0000563c38ad1abc
clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*,
llvm::BasicBlock*, llvm::BasicBlock*, unsigned long)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2fbcabc)
#10 0x0000563c38a89e9a
clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2f74e9a)
#11 0x0000563c38a89239 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2f74239)
#12 0x0000563c38a896dc
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2f746dc)
#13 0x0000563c38ad2241
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2fbd241)
#14 0x0000563c38adb9fe
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x2fc69fe)
#15 0x0000563c38b1b79a
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x300679a)
#16 0x0000563c38b196d5
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x30046d5)
#17 0x0000563c38b19de3
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x3004de3)
#18 0x0000563c38b1f081
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.4910)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x300a081)
#19 0x0000563c395896b1 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x3a746b1)
#20 0x0000563c3957c5e6
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x3a675e6)
#21 0x0000563c3a2f8eb4 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x47e3eb4)
#22 0x0000563c38fad809 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x3498809)
#23 0x0000563c38f6732b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x345232b)
#24 0x0000563c39073e9b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0x355ee9b)
#25 0x0000563c3699b7ac cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0xe867ac)
#26 0x0000563c369982ad ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0xe832ad)
#27 0x0000563c368d73a1 main
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0xdc23a1)
#28 0x00007f0f1680d0b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#29 0x0000563c36997e2a _start
(/opt/compiler-explorer/clang-11.0.1/bin/clang-11+0xe82e2a)
clang-11: error: unable to execute command: Segmentation fault (core dumped)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
Execution build compiler returned: 254

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210321/79bda76d/attachment-0001.html>


More information about the llvm-bugs mailing list