[llvm-bugs] [Bug 43168] New: Compiler crash when using `auto` for a parameter of a coroutine lambda

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 29 09:52:58 PDT 2019


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

            Bug ID: 43168
           Summary: Compiler crash when using `auto` for a parameter of a
                    coroutine lambda
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bartde at microsoft.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 22448
  --> https://bugs.llvm.org/attachment.cgi?id=22448&action=edit
Repro of the bug

Repro with clang trunk as of 8/28/2019 (clang version
9.0.0-svn370077-1~exp1~20190828074502.35) - https://godbolt.org/z/ySlZdn

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, https://reviews.llvm.org/D31487
caught my eye. It looks as if FindAllocationFunctions may potentially no longer
return false when OperatorNew isn't found.

-- 
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/20190829/3b0c870f/attachment.html>


More information about the llvm-bugs mailing list