[llvm-bugs] [Bug 25946] New: PPCaching.cpp:109 assert can be triggered by invalid code

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Dec 26 13:30:54 PST 2015


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

            Bug ID: 25946
           Summary: PPCaching.cpp:109 assert can be triggered by invalid
                    code
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bero at linaro.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Trying to build this code snippet with clang 3.7 causes a crash on an assert:

 template < T >
  class A
  template < typename T >
  class B:  T 
  A < > 


No optimization flags etc. needed.

The error is:
compress-5eaa12.cpp:1:13: error: unknown type name 'T'
 template < T >
            ^
compress-5eaa12.cpp:2:10: error: expected ';' after class
  class A
         ^
         ;                                                                      
clang-3.7: ../tools/clang/lib/Lex/PPCaching.cpp:109: void
clang::Preprocessor::AnnotatePreviousCachedTokens(const clang::Token &):
Assertion `(BacktrackPositions.empty() || BacktrackPositions.back() < i) &&
"The backtrack pos points inside the annotated tokens!"' failed.
#0 0x3a2d496173 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib64/libLLVMSupport.so.3.7+0x3a2d496173)
#1 0x3a2d496f75 (/usr/lib64/libLLVMSupport.so.3.7+0x3a2d496f75)
#2 0x37d322f7f0 __restore_rt (/lib64/libc.so.6+0x37d322f7f0)
#3 0x37d322f7a3 __GI_raise (/lib64/libc.so.6+0x37d322f7a3)
#4 0x37d32306c2 __GI_abort (/lib64/libc.so.6+0x37d32306c2)
#5 0x37d3229e62 __GI___assert_fail (/lib64/libc.so.6+0x37d3229e62)
#6 0x37d3229ea6 __GI___assert_perror_fail (/lib64/libc.so.6+0x37d3229ea6)
#7 0x3a3603fc21 (/usr/lib64/libclangLex.so.3.7+0x3a3603fc21)
#8 0x3a3bc84cc0
clang::Parser::AnnotateTemplateIdToken(clang::OpaquePtr<clang::TemplateName>,
clang::TemplateNameKind, clang::CXXScopeSpec&, clang::SourceLocation,
clang::UnqualifiedId&, bool) (/usr/lib64/libclangParse.so.3.7+0x3a3bc84cc0)
#9 0x3a3bc5e30a
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool*, bool, clang::IdentifierInfo**)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc5e30a)
#10 0x3a3bc39bc7 clang::Parser::isConstructorDeclarator(bool)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc39bc7)
#11 0x3a3bc48e35
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) (/usr/lib64/libclangParse.so.3.7+0x3a3bc48e35)
#12 0x3a3bc47768 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc47768)
#13 0x3a3bc34101 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc34101)
#14 0x3a3bc82930 clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned
int, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc82930)
#15 0x3a3bc825d4
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc825d4)
#16 0x3a3bc82137 clang::Parser::ParseDeclarationStartingWithTemplate(unsigned
int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc82137)
#17 0x3a3bc33927 clang::Parser::ParseDeclaration(unsigned int,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc33927)
#18 0x3a3bc895d6
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/lib64/libclangParse.so.3.7+0x3a3bc895d6)
#19 0x3a3bc8945d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc8945d)
#20 0x3a3bc29e07 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/lib64/libclangParse.so.3.7+0x3a3bc29e07)
#21 0x3a3c973577 clang::CodeGenAction::ExecuteAction()
(/usr/lib64/libclangCodeGen.so.3.7+0x3a3c973577)
#22 0x3a3c08ad69 clang::FrontendAction::Execute()
(/usr/lib64/libclangFrontend.so.3.7+0x3a3c08ad69)
#23 0x3a3c06a930 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/lib64/libclangFrontend.so.3.7+0x3a3c06a930)
#24 0x3a3a802de4 clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/lib64/libclangFrontendTool.so.3.7+0x3a3a802de4)
#25 0x40f04e cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/bin/clang-3.7+0x40f04e)
#26 0x40bdb7 main (/usr/bin/clang-3.7+0x40bdb7)
#27 0x37d3220efc __libc_start_main (/lib64/libc.so.6+0x37d3220efc)
#28 0x40b8a9 _start (/usr/bin/clang-3.7+0x40b8a9)
Stack dump:
0.      Program arguments: /usr/bin/clang-3.7 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
compress-5eaa12.cpp -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
-coverage-file /home/bero/Downloads/compress-5eaa12.cpp -resource-dir
/usr/bin/../lib64/clang/3.7.0 -internal-isystem
/usr/bin/../lib64/gcc/x86_64-mandriva-linux-gnu/5.3.1/../../../../include/c++/5.3.1
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-mandriva-linux-gnu/5.3.1/../../../../include/c++/5.3.1/x86_64-mandriva-linux-gnu
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-mandriva-linux-gnu/5.3.1/../../../../include/c++/5.3.1/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib64/clang/3.7.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/bero/Downloads -ferror-limit 19 -fmessage-length
142 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o compress-5eaa12.o -x c++
compress-5eaa12.cpp 
1.      compress-5eaa12.cpp:5:3: at annotation token
2.      compress-5eaa12.cpp:4:3: parsing struct/union/class body 'B'
clang-3.7: error: unable to execute command: Aborted (core dumped)
clang-3.7: error: clang frontend command failed due to signal (use -v to see
invocation)


The code was generated while running creduce on the sample in bug 25944 with an
oversimplified script (that just checked for "Assertion.*failed"), but it looks
like this is actually a separate issue.

-- 
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/20151226/6c42bbbd/attachment.html>


More information about the llvm-bugs mailing list