[LLVMbugs] [Bug 20817] New: Segfault in llvm::sys::PrintStackTrace with invalid decltype on a generic lambda

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Aug 30 07:37:54 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20817

            Bug ID: 20817
           Summary: Segfault in llvm::sys::PrintStackTrace with invalid
                    decltype on a generic lambda
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++1y
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aaronmcdaid at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12965
  --> http://llvm.org/bugs/attachment.cgi?id=12965&action=edit
preprocessed source code

(run script, code, and backtrace are in this message below. I've attached the
source itself.)

This sort piece of code crashes clang-3.4.2 with a segfault. If I comment out
the decltype, I get a normal error message.

It's a pretty obscure piece of code! I was working on continutations and
attempting to implement callCC when it first crashed after I used decltype.
I've simplified it greatly to this short piece of code.

I'm on Ubuntuo 12.04, using the pre-built binaries from
http://llvm.org/releases/3.4.2/clang+llvm-3.4.2-x86_64-unknown-ubuntu12.04.xz

Thanks,
Aaron

== /tmp/template-c0656e.sh ==

 "/home/aaron/prefix-clang-3.4.2/bin/clang" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name template.cpp -mrelocation-model static
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.22
-Wall -Wextra -std=c++1y -fdeprecated-macro -ferror-limit 19 -fmessage-length
169 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -x c++
template-c0656e.cpp

== /tmp/template-c0656e.cpp ==

# 1 "<built-in>" 1
# 1 "template.cpp" 1
auto b = [](auto ) -> decltype(THIS_DECLTYPE_CRASHES_THE_COMPILER)
{
        return;
};

template<typename T>
auto a (T f) {
                return f;
};

int main() {
        a( b ) (3) ;
}

== stack trace ==

template.cpp:1:32: error: use of undeclared identifier
'THIS_DECLTYPE_CRASHES_THE_COMPILER'
auto b = [](auto ) -> decltype(THIS_DECLTYPE_CRASHES_THE_COMPILER)
                               ^
template.cpp:3:2: error: non-void block should return a value
        return;
        ^
0  clang           0x0000000001d8e065 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1  clang           0x0000000001d8e4a3
2  libpthread.so.0 0x00007ff3bcf8fcb0
3  clang           0x0000000001090b30 clang::ParmVarDecl::isParameterPack()
const + 0
4  clang           0x0000000000c6b771
clang::TemplateDeclInstantiator::SubstFunctionType(clang::FunctionDecl*,
llvm::SmallVectorImpl<clang::ParmVarDecl*>&) + 1025
5  clang           0x0000000000c6910b
clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*,
clang::TemplateParameterList*, bool) + 795
6  clang           0x0000000000c6bbe8 clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) + 136
7  clang           0x0000000000c25391
clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*,
llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&,
llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*) + 1857
8  clang           0x0000000000c2724d
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>,
clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&) + 3965
9  clang           0x0000000000bb3f80
clang::Sema::AddMethodTemplateCandidate(clang::FunctionTemplateDecl*,
clang::DeclAccessPair, clang::CXXRecordDecl*, clang::TemplateArgumentListInfo*,
clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>,
clang::OverloadCandidateSet&, bool) + 288
10 clang           0x0000000000bc416a
clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation) + 1050
11 clang           0x0000000000aef330 clang::Sema::ActOnCallExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool) + 1312
12 clang           0x000000000099b1ff
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) + 2207
13 clang           0x000000000099d6c9 clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::Parser::TypeCastState) + 6377
14 clang           0x00000000009995c0
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 128
15 clang           0x0000000000999529
clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 9
16 clang           0x00000000009c5879 clang::Parser::ParseExprStatement() + 41 
17 clang           0x00000000009c5241
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
+ 2897
18 clang           0x00000000009c4680
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) + 144
19 clang           0x00000000009cae54
clang::Parser::ParseCompoundStatementBody(bool) + 1540
20 clang           0x00000000009cdf60
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 176
21 clang           0x000000000096c1ed
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
2925
22 clang           0x000000000097a976
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1302
23 clang           0x000000000096b588
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 648
24 clang           0x000000000096b107
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 375
25 clang           0x000000000096a675
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 2197
26 clang           0x0000000000969d62
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 386
27 clang           0x0000000000966f56 clang::ParseAST(clang::Sema&, bool, bool)
+ 454
28 clang           0x00000000008197b9 clang::CodeGenAction::ExecuteAction() +
73
29 clang           0x00000000006b0df1 clang::FrontendAction::Execute() + 81
30 clang           0x000000000068fced
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 813
31 clang           0x000000000067a2ed
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2877
32 clang           0x0000000000672f1e cc1_main(char const**, char const**, char
const*, void*) + 654
33 clang           0x00000000006787fa main + 8314
34 libc.so.6       0x00007ff3bbd9c76d __libc_start_main + 237
35 clang           0x0000000000672bcd
Stack dump:
0.      Program arguments: /home/aaron/prefix-clang-3.4.2/bin/clang -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name template.cpp -mrelocation-model static
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.22
-resource-dir /home/aaron/prefix-clang-3.4.2/bin/../lib/clang/3.4.2
-internal-isystem
/home/aaron/prefix-gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../include/c++/4.8.2
-internal-isystem
/home/aaron/prefix-gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../include/c++/4.8.2/x86_64-unknown-linux-gnu
-internal-isystem
/home/aaron/prefix-gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../include/c++/4.8.2/backward
-internal-isystem
/home/aaron/prefix-gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../include/x86_64-unknown-linux-gnu/c++/4.8.2
-internal-isystem /usr/local/include -internal-isystem
/home/aaron/prefix-clang-3.4.2/bin/../lib/clang/3.4.2/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall
-Wextra -std=c++1y -fdeprecated-macro -fdebug-compilation-dir
/home/aaron/Code/MyCode/FunStuff/2014-08/29-continuations-in-heterogenous-lists
-ferror-limit 19 -fmessage-length 169 -mstackrealign -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-slp -o /tmp/template-17b68f.o -x c++ template.cpp
1.      template.cpp:12:11: current parser token ')'
2.      template.cpp:11:12: parsing function body 'main'
3.      template.cpp:11:12: in compound statement ('{}')
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.4.2 (tags/RELEASE_34/dot2-rc1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: 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: note: diagnostic msg:
********************

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

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

-- 
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/20140830/940daf0b/attachment.html>


More information about the llvm-bugs mailing list