[llvm-bugs] [Bug 25700] New: Parsing segfault

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 1 17:31:08 PST 2015


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

            Bug ID: 25700
           Summary: Parsing segfault
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kmod at dropbox.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Test case:

template<typename _Alloc> class _Rb_tree {
    template<typename _Alloc> _Rb_tree<_Alloc>::operator=() noexcept(true) {}
};

To reproduce:

$ clang++ -cc1 -std=c++11 -x c++ test.cpp
1656.c:2:23: error: declaration of '_Alloc' shadows template parameter
    template<typename _Alloc> _Rb_tree<_Alloc>::operator=() noexcept(true) {}
                      ^
1656.c:1:19: note: template parameter is declared here
template<typename _Alloc> class _Rb_tree {
                  ^
1656.c:2:49: error: nested name specifier '_Rb_tree<_Alloc>::' for declaration
does not refer into a class, class template or class template partial
specialization
    template<typename _Alloc> _Rb_tree<_Alloc>::operator=() noexcept(true) {}
                              ~~~~~~~~~~~~~~~~~~^
0  libLLVM-3.7.so.1 0x00007fae4f43d730
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 64
1  libLLVM-3.7.so.1 0x00007fae4f43cb91
2  libpthread.so.0  0x00007fae4ed47d10
3  clang++          0x0000000000aa8fe7
clang::Parser::ParseLexedMethodDeclaration(clang::Parser::LateParsedMethodDeclaration&)
+ 1959
4  clang++          0x0000000000aa8776
clang::Parser::ParseLexedMethodDeclarations(clang::Parser::ParsingClass&) + 166
5  clang++          0x0000000000a5096c
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) + 2748
6  clang++          0x0000000000a51c56
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&) + 3206
7  clang++          0x0000000000a3383b
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) + 3435
8  clang++          0x0000000000aa2910
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 960
9  clang++          0x0000000000aa403d
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 989
10 clang++          0x0000000000aa432f
clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 111
11 clang++          0x0000000000a3ddb7 clang::Parser::ParseDeclaration(unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 583
12 clang++          0x0000000000a24d71
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 321
13 clang++          0x0000000000a25729
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 441
14 clang++          0x0000000000a1aa10 clang::ParseAST(clang::Sema&, bool,
bool) + 560
15 clang++          0x00000000006a352e clang::FrontendAction::Execute() + 510
16 clang++          0x000000000067a5c9
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 313
17 clang++          0x0000000000661f63
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1955
18 clang++          0x000000000065ca18 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 2232
19 clang++          0x000000000065948e main + 1006
20 libc.so.6        0x00007fae4e3f4a40 __libc_start_main + 240
21 clang++          0x000000000065ba89 _start + 41
Stack dump:
0.      Program arguments: clang++ -cc1 -std=c++11 -x c++ 1656.c 
1.      1656.c:2:61: current parser token 'noexcept'
2.      1656.c:1:27: parsing struct/union/class body '_Rb_tree'
Segmentation fault (core dumped)


I'm seeing this on the ubuntu clang-3.7 package, and also with a freshly built
clang (r254464)



This was automatically reduced from our code, but I'm not sure the minimized
example exhibits the same issue as the original code since the stack traces are
quite different.  I've attached the full original code in case it helps.  That
code is failing with:

$ bash objmodel-c2d982.sh
0  libLLVM-3.7.so.1 0x00007f5d1b453730
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 64
1  libLLVM-3.7.so.1 0x00007f5d1b452b91
2  libpthread.so.0  0x00007f5d1ad5dd10
3  clang            0x00000000012f2718 clang::Expr::IgnoreParens() + 8
4  clang            0x00000000012f334d clang::Expr::IgnoreParenImpCasts() + 13
5  clang            0x0000000000c664f9
6  clang            0x0000000000c66a77
7  clang            0x0000000000c7d4d4
8  clang            0x0000000000c7e7ac
clang::Sema::ActOnCXXDelete(clang::SourceLocation, bool, bool, clang::Expr*) +
284
9  clang            0x0000000000e1351d
10 clang            0x0000000000e0f5d6
11 clang            0x0000000000e1dcbd
12 clang            0x0000000000e1f15b
13 clang            0x0000000000e1f29b
14 clang            0x0000000000e1dfe5
15 clang            0x0000000000e2191f clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&) + 95
16 clang            0x0000000000e34fcc
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 3756
17 clang            0x0000000000e352aa
clang::Sema::PerformPendingInstantiations(bool) + 298
18 clang            0x0000000000acffb5 clang::Sema::ActOnEndOfTranslationUnit()
+ 341
19 clang            0x0000000000a257c9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 601
20 clang            0x0000000000a1a9d3 clang::ParseAST(clang::Sema&, bool,
bool) + 499
21 clang            0x00000000006a352e clang::FrontendAction::Execute() + 510
22 clang            0x000000000067a5c9
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 313
23 clang            0x0000000000661f63
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1955
24 clang            0x000000000065ca18 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 2232
25 clang            0x000000000065948e main + 1006
26 libc.so.6        0x00007f5d1a40aa40 __libc_start_main + 240
27 clang            0x000000000065ba89 _start + 41
Stack dump:
0.      Program arguments: /usr/lib/llvm-3.7/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-main-file-name objmodel.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 -target-linker-version
2.25.1 -g -dwarf-column-info -ffunction-sections -fdata-sections -D
DEFAULT_PYTHON_MAJOR_VERSION=2 -D DEFAULT_PYTHON_MICRO_VERSION=6 -D
DEFAULT_PYTHON_MINOR_VERSION=7 -D LLVMREV=230300 -D NVALGRIND -D
THREADING_USE_GIL=1 -D THREADING_USE_GRWL=0 -D __STDC_CONSTANT_MACROS -D
__STDC_LIMIT_MACROS -D BINARY_SUFFIX= -D BINARY_STRIPPED_SUFFIX=_stripped -D
Py_BUILD_CORE -Wall -Wextra -Werror -Wreturn-type -Wno-sign-compare -Wno-unused
-Wno-unused-parameter -Woverloaded-virtual -Wno-invalid-offsetof -Wcast-qual
-Wno-sign-conversion -Wnon-virtual-dtor -Winit-self -Wmissing-include-dirs
-Wstrict-overflow=5 -Wpointer-arith -Wtype-limits -Wwrite-strings -Wempty-body
-Waggregate-return -Wmissing-field-initializers -Wredundant-decls -Winline
-Wint-to-pointer-cast -Wlong-long -Wvla -Wno-attributes -Wimplicit-int
-Wstrict-prototypes -Wold-style-definition -Wnested-externs
-Wpointer-to-int-cast -Wno-mismatched-tags -Wno-extern-c-compat -std=c++11
-fdeprecated-macro -ferror-limit 19 -fmessage-length 0
-fvisibility-inlines-hidden -mstackrealign -fno-rtti -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -x
c++ objmodel-c2d982.cpp
1.      <eof> parser at end of file
2.      ../../src/gc/gc.h:224:5: instantiating function definition
'~UniqueScanningHandle'

-- 
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/20151202/b42391dc/attachment.html>


More information about the llvm-bugs mailing list