<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Compiler crash when using `auto` for a parameter of a coroutine lambda"
href="https://bugs.llvm.org/show_bug.cgi?id=43168">43168</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compiler crash when using `auto` for a parameter of a coroutine lambda
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++2a
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>bartde@microsoft.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22448" name="attach_22448" title="Repro of the bug">attachment 22448</a> <a href="attachment.cgi?id=22448&action=edit" title="Repro of the bug">[details]</a></span>
Repro of the bug
Repro with clang trunk as of 8/28/2019 (clang version
9.0.0-svn370077-1~exp1~20190828074502.35) - <a href="https://godbolt.org/z/ySlZdn">https://godbolt.org/z/ySlZdn</a>
The essence boils down to:
void f()
{
g([](auto) -> task<bool> { co_return true; });
}
crashing, while
void f()
{
g([](int) -> task<bool> { co_return true; });
}
doesn't crash. The only difference is the use of auto.
The crash stack trace is:
#0 0x00007fa22d15401f llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xa3701f)
#1 0x00007fa22d152440 llvm::sys::RunSignalHandlers()
(/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xa35440)
#2 0x00007fa22d154421 (/usr/lib/x86_64-linux-gnu/libLLVM-9.so.1+0xa37421)
#3 0x00007fa232dca890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
#4 0x00007fa2312bba8e getStmtClass
/build/llvm-toolchain-9-9~svn370077/tools/clang/include/clang/AST/Stmt.h:1088:44
#5 0x00007fa2312bba8e clang::Expr::getExprLoc() const
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/AST/Expr.cpp:216:11
#6 0x00007fa231bf5977
clang::CodeGen::ApplyDebugLocation::ApplyDebugLocation(clang::CodeGen::CodeGenFunction&,
clang::Expr const*)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CGDebugInfo.cpp:123:3
#7 0x00007fa231c679d2 Visit
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CGExprScalar.cpp:423:24
#8 0x00007fa231c679d2
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CGExprScalar.cpp:4436:8
#9 0x00007fa231bf1907
clang::CodeGen::CodeGenFunction::EmitCoroutineBody(clang::CoroutineBodyStmt
const&)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CGCoroutine.cpp:568:24
#10 0x00007fa231d4b7cb clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CGStmt.cpp:150:5
#11 0x00007fa231d8fa9f getLangOpts
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenFunction.h:1630:51
#12 0x00007fa231d8fa9f
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1208:7
#13 0x00007fa231da6d6e
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenModule.cpp:4320:3
#14 0x00007fa231da143d isVirtual
/build/llvm-toolchain-9-9~svn370077/tools/clang/include/clang/AST/DeclCXX.h:2158:59
#15 0x00007fa231da143d
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenModule.cpp:2751:19
#16 0x00007fa231d980d3 begin
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_vector.h:573:45
#17 0x00007fa231d980d3 empty
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_vector.h:760:16
#18 0x00007fa231d980d3 clang::CodeGen::CodeGenModule::EmitDeferred()
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenModule.cpp:2123:26
#19 0x00007fa231d98068 operator++
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_iterator.h:802:2
#20 0x00007fa231d98068 clang::CodeGen::CodeGenModule::EmitDeferred()
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenModule.cpp:2091:22
#21 0x00007fa231d98068 operator++
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_iterator.h:802:2
#22 0x00007fa231d98068 clang::CodeGen::CodeGenModule::EmitDeferred()
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenModule.cpp:2091:22
#23 0x00007fa231d98068 operator++
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_iterator.h:802:2
#24 0x00007fa231d98068 clang::CodeGen::CodeGenModule::EmitDeferred()
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenModule.cpp:2091:22
#25 0x00007fa231d97507 __normal_iterator
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_iterator.h:780:20
#26 0x00007fa231d97507 begin
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_vector.h:564:16
#27 0x00007fa231d97507 EmitVTablesOpportunistically
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenModule.cpp:2139:32
#28 0x00007fa231d97507 clang::CodeGen::CodeGenModule::Release()
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenModule.cpp:394:3
#29 0x00007fa231e11234 HandleTranslationUnit
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/ModuleBuilder.cpp:260:11
#30 0x00007fa231d87f76 HandleTranslationUnit
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/CodeGen/CodeGenAction.cpp:240:13
#31 0x00007fa2310b9e13 __normal_iterator
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_iterator.h:780:20
#32 0x00007fa2310b9e13 begin
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/stl_vector.h:564:16
#33 0x00007fa2310b9e13
finalize<std::vector<std::unique_ptr<clang::TemplateInstantiationCallback,
std::default_delete<clang::TemplateInstantiationCallback> >,
std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback,
std::default_delete<clang::TemplateInstantiationCallback> > > > >
/build/llvm-toolchain-9-9~svn370077/tools/clang/include/clang/Sema/TemplateInstCallback.h:54:16
#34 0x00007fa2310b9e13 clang::ParseAST(clang::Sema&, bool, bool)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/Parse/ParseAST.cpp:178:3
#35 0x00007fa232355688 clang::FrontendAction::Execute()
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/Frontend/FrontendAction.cpp:938:10
#36 0x00007fa232315e30 getPtr
/build/llvm-toolchain-9-9~svn370077/include/llvm/Support/Error.h:273:42
#37 0x00007fa232315e30 operator bool
/build/llvm-toolchain-9-9~svn370077/include/llvm/Support/Error.h:236:16
#38 0x00007fa232315e30
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/Frontend/CompilerInstance.cpp:944:23
#39 0x00007fa2323b80f0
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/build/llvm-toolchain-9-9~svn370077/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:291:25
#40 0x0000000000498ae6 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-9/bin/clang+0x498ae6)
#41 0x0000000000496e51 main (/usr/lib/llvm-9/bin/clang+0x496e51)
#42 0x00007fa22ba0eb97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#43 0x00000000004942fa _start (/usr/lib/llvm-9/bin/clang+0x4942fa)
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 9.0.0-svn370077-1~exp1~20190828074502.35 (branches/release_90)
It looks like there may be some code path where the allocator expression which
is passed to EmitScalarExpr in EmitCoroutineBody is null. I haven't dug too
deep, but upon looking at recent changes, <a href="https://reviews.llvm.org/D31487">https://reviews.llvm.org/D31487</a>
caught my eye. It looks as if FindAllocationFunctions may potentially no longer
return false when OperatorNew isn't found.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>