[llvm-bugs] [Bug 28861] New: crash on invalid C++ code on x86_64-linux-gnu (Assertion `(BacktrackPositions.empty() || BacktrackPositions.back() < i) && "The backtrack pos points inside the annotated tokens!"' failed)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 5 00:22:17 PDT 2016


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

            Bug ID: 28861
           Summary: crash on invalid C++ code on x86_64-linux-gnu
                    (Assertion `(BacktrackPositions.empty() ||
                    BacktrackPositions.back() < i) && "The backtrack pos
                    points inside the annotated tokens!"' failed)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following bug is sensitive to the format. If I move
"ParserBase<PreParserTraits>
" to the previous line, then the bug disappears. 

$ clang++-trunk -v
clang version 4.0.0 (trunk 277732)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.1.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang++-trunk small.C
clang-4.0:
/tmp/llvm-builder/llvm-source-trunk/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 0x0000000001b7d425 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1b7d425)
#1 0x0000000001b7b14e llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1b7b14e)
#2 0x0000000001b7b2b2 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1b7b2b2)
#3 0x00007feca6c99ed0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10ed0)
#4 0x00007feca582e1c8 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x331c8)
#5 0x00007feca582f64a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3464a)
#6 0x00007feca5827107 (/lib/x86_64-linux-gnu/libc.so.6+0x2c107)
#7 0x00007feca58271b2 (/lib/x86_64-linux-gnu/libc.so.6+0x2c1b2)
#8 0x00000000031777f7 (/usr/local/clang-trunk/bin/clang-4.0+0x31777f7)
#9 0x0000000002683171
clang::Parser::AnnotateTemplateIdToken(clang::OpaquePtr<clang::TemplateName>,
clang::TemplateNameKind, clang::CXXScopeSpec&, clang::SourceLocation,
clang::UnqualifiedId&, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2683171)
#10 0x0000000002643b97
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool*, bool, clang::IdentifierInfo**)
(/usr/local/clang-trunk/bin/clang-4.0+0x2643b97)
#11 0x0000000002606c75 clang::Parser::isConstructorDeclarator(bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2606c75)
#12 0x000000000262b941
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) (/usr/local/clang-trunk/bin/clang-4.0+0x262b941)
#13 0x000000000262c4ec
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-4.0+0x262c4ec)
#14 0x000000000260f388
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x260f388)
#15 0x00000000025f50a4
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-4.0+0x25f50a4)
#16 0x00000000025f5821
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.158] [clone
.constprop.181] (/usr/local/clang-trunk/bin/clang-4.0+0x25f5821)
#17 0x00000000025f586f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-4.0+0x25f586f)
#18 0x00000000025fac0f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-4.0+0x25fac0f)
#19 0x00000000025fb549
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-4.0+0x25fb549)
#20 0x00000000025f0d0b clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x25f0d0b)
#21 0x00000000022d9667 clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x22d9667)
#22 0x0000000001fff7a6 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x1fff7a6)
#23 0x0000000001fd3836
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1fd3836)
#24 0x0000000002083f47
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2083f47)
#25 0x0000000000941778 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0x941778)
#26 0x00000000008deb60 main (/usr/local/clang-trunk/bin/clang-4.0+0x8deb60)
#27 0x00007feca581b730 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x20730)
#28 0x000000000093dff9 _start (/usr/local/clang-trunk/bin/clang-4.0+0x93dff9)
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.C -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
-resource-dir /usr/local/clang-trunk/bin/../lib/clang/4.0.0 -c-isystem .
-c-isystem /usr/local/include/csmith -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/x86_64-linux-gnu/c++/6.1.1
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/x86_64-linux-gnu/c++/6.1.1
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.1.1/../../../../include/c++/6.1.1/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/4.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/cnsun/workspace/meta-compiler/error-fuzzer/exp-runs/crash/RandomTokenManipulationFuzzingEngine/20160804-clang++-trunk--O3-c-Weverything-std=c++14-build-212451
-ferror-limit 19 -fmessage-length 135 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/small-a2c030.o -x c++ small.C
1.    small.C:8:10: at annotation token
2.    small.C:7:1: parsing struct/union/class body 'T'
clang-4.0: error: unable to execute command: Aborted
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 277732)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-4.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-4.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-4.0: note: diagnostic msg: /tmp/small-da2596.cpp
clang-4.0: note: diagnostic msg: /tmp/small-da2596.sh
clang-4.0: note: diagnostic msg:

********************
$
$ cat small.C
template <typename T>
class ParserBase;
class PreParserTraits {
public:
  struct Type {};
};
class T: PreParserTraits::Type
         ParserBase<PreParserTraits>
{};

-- 
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/20160805/9769894a/attachment-0001.html>


More information about the llvm-bugs mailing list