[llvm-bugs] [Bug 46985] New: Clang crashed in llvm/include/llvm/ADT/SmallVector.h:194 llvm::SmallVectorTemplateCommon::reference llvm::SmallVectorTemplateCommon<clang::InventedTemplateParameterInfo, void>::back() [T = clang::InventedTemplateParameterInfo]: Assertion `!empty()' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 4 08:16:34 PDT 2020


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

            Bug ID: 46985
           Summary: Clang crashed in
                    llvm/include/llvm/ADT/SmallVector.h:194
                    llvm::SmallVectorTemplateCommon::reference
                    llvm::SmallVectorTemplateCommon<clang::InventedTemplat
                    eParameterInfo, void>::back() [T =
                    clang::InventedTemplateParameterInfo]: Assertion
                    `!empty()' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: crash-on-invalid
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi, all.

This small invalid code makes Clang-trunk crashed, while clang-10 and downwards
versions perform well in error-recovery.

Input:
//small.cc
template <(enum a()->auto)> class A {};


Command:
clang++ small.cc

Output:
small.cc:1:17: error: ISO C++ forbids forward references to 'enum' types
template <(enum a()->auto)> class A {};
                ^
small.cc:1:12: error: function with trailing return type must specify return
type 'auto', not 'enum a'
template <(enum a()->auto)> class A {};
           ^
clang-12:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/llvm/include/llvm/ADT/SmallVector.h:194:
llvm::SmallVectorTemplateCommon::reference
llvm::SmallVectorTemplateCommon<clang::InventedTemplateParameterInfo,
void>::back() [T = clang::InventedTemplateParameterInfo]: Assertion `!empty()'
failed.
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:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name small.cc -mrelocation-model static -mframe-pointer=all
-fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/lib/clang/12.0.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward
-internal-isystem /usr/local/include -internal-isystem
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/lib/clang/12.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /home/haoxin/test/clang-bug
-ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions
-fcolor-diagnostics -faddrsig -o /tmp/small-c58711.o -x c++ small.cc 
1.      small.cc:1:26: current parser token ')'
 #0 0x0000000002758f44 PrintStackTraceSignalHandler(void*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2758f44)
 #1 0x0000000002756b4e llvm::sys::RunSignalHandlers()
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2756b4e)
 #2 0x0000000002759265 SignalHandler(int)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2759265)
 #3 0x00007fbb4bef7390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
 #4 0x00007fbb4aa61438 raise
/build/glibc-e6zv40/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
 #5 0x00007fbb4aa6303a abort /build/glibc-e6zv40/glibc-2.23/stdlib/abort.c:91:0
 #6 0x00007fbb4aa59be7 __assert_fail_base
/build/glibc-e6zv40/glibc-2.23/assert/assert.c:92:0
 #7 0x00007fbb4aa59c92 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc92)
 #8 0x0000000004881416 GetFullTypeForDeclarator((anonymous
namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x4881416)
 #9 0x000000000487571e clang::Sema::GetTypeForDeclarator(clang::Declarator&,
clang::Scope*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x487571e)
#10 0x000000000421ce49 clang::Sema::ActOnParamDeclarator(clang::Scope*,
clang::Declarator&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x421ce49)
#11 0x0000000003ff1498
clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext,
clang::ParsedAttributes&,
llvm::SmallVectorImpl<clang::DeclaratorChunk::ParamInfo>&,
clang::SourceLocation&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3ff1498)
#12 0x0000000003feee87
clang::Parser::ParseFunctionDeclarator(clang::Declarator&,
clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3feee87)
#13 0x0000000003fee0f7 clang::Parser::ParseParenDeclarator(clang::Declarator&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fee0f7)
#14 0x0000000003febda9 clang::Parser::ParseDirectDeclarator(clang::Declarator&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3febda9)
#15 0x0000000003feae66
clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void
(clang::Parser::*)(clang::Declarator&))
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3feae66)
#16 0x0000000004077a65 clang::Parser::ParseNonTypeTemplateParameter(unsigned
int, unsigned int)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x4077a65)
#17 0x0000000004075b0d clang::Parser::ParseTemplateParameterList(unsigned int,
llvm::SmallVectorImpl<clang::NamedDecl*>&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x4075b0d)
#18 0x00000000040740ff
clang::Parser::ParseTemplateParameters(clang::Parser::MultiParseScope&,
unsigned int, llvm::SmallVectorImpl<clang::NamedDecl*>&,
clang::SourceLocation&, clang::SourceLocation&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x40740ff)
#19 0x0000000004073bac
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x4073bac)
#20 0x000000000407382e
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x407382e)
#21 0x0000000003fdba00
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fdba00)
#22 0x0000000003fc35ba
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc35ba)
#23 0x0000000003fc1f7d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc1f7d)
#24 0x0000000003fc17c7
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc17c7)
#25 0x0000000003fbd27e clang::ParseAST(clang::Sema&, bool, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fbd27e)
#26 0x0000000002f2a393 clang::FrontendAction::Execute()
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2f2a393)
#27 0x0000000002ec4ea3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2ec4ea3)
#28 0x0000000002fd43b2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2fd43b2)
#29 0x0000000000983453 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x983453)
#30 0x00000000009818ec ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x9818ec)
#31 0x0000000000981594 main
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x981594)
#32 0x00007fbb4aa4c840 __libc_start_main
/build/glibc-e6zv40/glibc-2.23/csu/../csu/libc-start.c:325:0
#33 0x000000000097e5a9 _start
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x97e5a9)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 12.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin
clang-12: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/small-c55e0d.cpp
clang-12: note: diagnostic msg: /tmp/small-c55e0d.sh
clang-12: note: diagnostic msg: 

********************

Thanks,
Haoxin

-- 
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/20200804/ce447338/attachment-0001.html>


More information about the llvm-bugs mailing list