[llvm-bugs] [Bug 45093] New: Segfault in Parser

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 3 10:09:00 PST 2020


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

            Bug ID: 45093
           Summary: Segfault in Parser
           Product: clang
           Version: trunk
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: martongabesz 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 23198
  --> https://bugs.llvm.org/attachment.cgi?id=23198&action=edit
reproducer

The following file causes a segfault during parsing:

template <typename = typename a::template b < >=


And the trace is:
test.cpp:1:31: error: use of undeclared identifier 'a'
template <typename = typename a::template b < >=
                              ^
test.cpp:1:47: error: a space is required between a right angle bracket and an
equals sign (use '> =')
template <typename = typename a::template b < >=
                                              ^~
                                              > =
Stack dump:
0.      Program arguments:
/home/egbomrt/WORK/llvm3/build/release_assert/bin/clang-10 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test.cpp -mrelocation-model static -mthread-model posix -mframe-pointer=all
-fmath-errno -fdenormal-fp-math=ieee,ieee -fdenormal-fp-math-f32=ieee,ieee
-fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining
-debugger-tuning=gdb -resource-dir
/home/egbomrt/WORK/llvm3/build/release_assert/lib/clang/11.0.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward
-internal-isystem /usr/local/include -internal-isystem
/home/egbomrt/WORK/llvm3/build/release_assert/lib/clang/11.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/egbomrt/WORK/CodeCheckerProjects/bitcoin/reports-noctu/failed/ERR
-ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
-faddrsig -o /tmp/test-0cdada.o -x c++ test.cpp
1.      test.cpp:1:48: current parser token '='
 #0 0x00007f69ff36452a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/libLLVMSupport.so.11git+0x1a652a)
 #1 0x00007f69ff362014 llvm::sys::RunSignalHandlers()
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/libLLVMSupport.so.11git+0x1a4014)
 #2 0x00007f69ff362163 SignalHandler(int)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/libLLVMSupport.so.11git+0x1a4163)
 #3 0x00007f69fd2dbf20 (/lib/x86_64-linux-gnu/libc.so.6+0x3ef20)
 #4 0x00007f69fa9cc86c (anonymous
namespace)::UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier(clang::NestedNameSpecifier*)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangSema.so.11git+0x6d586c)
 #5 0x00007f69fa9cc721 clang::TypeVisitor<(anonymous
namespace)::UnnamedLocalNoLinkageFinder, bool>::Visit(clang::Type const*)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangSema.so.11git+0x6d5721)
 #6 0x00007f69fa9d221b
clang::Sema::CheckTemplateArgument(clang::TemplateTypeParmDecl*,
clang::TypeSourceInfo*)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangSema.so.11git+0x6db21b)
 #7 0x00007f69fa9d4220 clang::Sema::ActOnTypeParameter(clang::Scope*, bool,
clang::SourceLocation, clang::SourceLocation, clang::IdentifierInfo*,
clang::SourceLocation, unsigned int, unsigned int, clang::SourceLocation,
clang::OpaquePtr<clang::QualType>, bool)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangSema.so.11git+0x6dd220)
 #8 0x00007f69faf9caf4 clang::Parser::ParseTypeParameter(unsigned int, unsigned
int)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xcfaf4)
 #9 0x00007f69fafa0d08 clang::Parser::ParseTemplateParameter(unsigned int,
unsigned int)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xd3d08)
#10 0x00007f69fafa1c2e clang::Parser::ParseTemplateParameterList(unsigned int,
llvm::SmallVectorImpl<clang::NamedDecl*>&)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xd4c2e)
#11 0x00007f69fafa1fd0 clang::Parser::ParseTemplateParameters(unsigned int,
llvm::SmallVectorImpl<clang::NamedDecl*>&, clang::SourceLocation&,
clang::SourceLocation&)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xd4fd0)
#12 0x00007f69fafa5756
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xd8756)
#13 0x00007f69fafa5cf9
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xd8cf9)
#14 0x00007f69faf22b06
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0x55b06)
#15 0x00007f69fafb53cd
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xe83cd)
#16 0x00007f69fafb66e9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xe96e9)
#17 0x00007f69fafb6b17
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0xe9b17)
#18 0x00007f69faeff9b3 clang::ParseAST(clang::Sema&, bool, bool)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/../lib/libclangParse.so.11git+0x329b3)
#19 0x00007f69fe4ac348 clang::CodeGenAction::ExecuteAction()
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/libclangCodeGen.so.11git+0x3eb348)
#20 0x00007f69fdd8d949 clang::FrontendAction::Execute()
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/libclangFrontend.so.11git+0xf6949)
#21 0x00007f69fdd42ee2
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/libclangFrontend.so.11git+0xabee2)
#22 0x00007f6a018ab8dc
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/../lib/libclangFrontendTool.so.11git+0x48dc)
#23 0x000055d917866754 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/egbomrt/WORK/llvm3/build/release_assert/bin/clang-10+0x13754)
#24 0x000055d917861a99 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/clang-10+0xea99)
#25 0x000055d91785f8ff main
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/clang-10+0xc8ff)
#26 0x00007f69fd2beb97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#27 0x000055d9178615fa _start
(/home/egbomrt/WORK/llvm3/build/release_assert/bin/clang-10+0xe5fa)
clang-10: error: unable to execute command: Segmentation fault (core dumped)
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.0.0 (git at github.com:martong/llvm-project.git
6304368818a1e9883b694b9d8c21ef568176168d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/egbomrt/WORK/llvm3/build/release_assert/bin
clang-10: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-10: note: diagnostic msg:
********************

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

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


Version:
clang version 11.0.0 (git at github.com:martong/llvm-project.git
6304368818a1e9883b694b9d8c21ef568176168d)
Target: x86_64-unknown-linux-gnu

-- 
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/20200303/e49f9cae/attachment.html>


More information about the llvm-bugs mailing list