Closed
Description
A small source code:
#include <coroutine>
#include <cstddef>
struct alignas(std::max_align_t) promise_base {
int count = 0;
};
struct task{
struct promise_type : promise_base {
task get_return_object() { return std::coroutine_handle<promise_type>::from_promise(*this); }
std::suspend_always initial_suspend() { return {}; }
std::suspend_always final_suspend() noexcept { return {}; }
void return_void() noexcept {}
void unhandled_exception() noexcept {}
int b;
};
void resume() noexcept {
handle.resume();
}
task(std::coroutine_handle<promise_type> hdl) : handle(hdl) {}
~task() {
if (handle)
handle.destroy();
}
std::coroutine_handle<> handle;
};
task coro_task(int v) {
int a = v;
__builtin_debugtrap();
co_return;
}
int main() {
auto k = coro_task(1);
k.resume();
return 0;
}
Reproduce steps:
$ ./bin/clang++ -std=c++20 -g /tmp/t.cpp -o /tmp/debugging-example
$ ./bin/lldb --one-line "run" --one-line "expr __promise" /tmp/debugging-example
We hit an assertion, stack trace:
assert.h assertion failed at llvm-project/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:754 in void (anonymous namespace)::CGRecordLowering::clipTailPadding(): Prior->Kind == MemberInfo::Field && "Only storage fields have tail padding!"
*** Check failure stack trace: ***
@ absl::log_internal::LogMessage::SendToLog()
@ absl::log_internal::LogMessage::Flush()
@ absl::log_internal::LogMessageFatal::~LogMessageFatal()
@ __assert_fail
@ (anonymous namespace)::CGRecordLowering::lower()
@ clang::CodeGen::CodeGenTypes::ComputeRecordLayout()
@ clang::CodeGen::CodeGenTypes::ConvertRecordDeclType()
@ clang::CodeGen::CodeGenTypes::ConvertType()
@ clang::CodeGen::CodeGenTypes::ConvertTypeForMem()
@ clang::CodeGen::CodeGenFunction::EmitLoadOfReference()
@ clang::CodeGen::CodeGenFunction::EmitLoadOfReferenceLValue()
@ clang::CodeGen::CodeGenFunction::EmitDeclRefLValue()
@ clang::CodeGen::CodeGenFunction::EmitLValueHelper()
@ clang::CodeGen::CodeGenFunction::EmitLValue()
@ (anonymous namespace)::ScalarExprEmitter::VisitUnaryAddrOf()
@ clang::StmtVisitorBase<>::Visit()
@ clang::CodeGen::CodeGenFunction::EmitScalarExpr()
@ clang::CodeGen::CodeGenFunction::EmitScalarInit()
@ clang::CodeGen::CodeGenFunction::EmitCXXGlobalVarDeclInit()
@ (anonymous namespace)::ItaniumCXXABI::EmitGuardedInit()
@ clang::CodeGen::CodeGenFunction::AddInitializerToStaticVarDecl()
@ clang::CodeGen::CodeGenFunction::EmitStaticVarDecl()
@ clang::CodeGen::CodeGenFunction::EmitDecl()
@ clang::CodeGen::CodeGenFunction::EmitDeclStmt()
@ clang::CodeGen::CodeGenFunction::EmitSimpleStmt()
@ clang::CodeGen::CodeGenFunction::EmitStmt()
@ clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope()
@ clang::CodeGen::CodeGenFunction::GenerateCode()
@ clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition()
@ clang::CodeGen::CodeGenModule::EmitGlobalDefinition()
@ clang::CodeGen::CodeGenModule::EmitGlobal()
@ clang::CodeGen::CodeGenModule::EmitTopLevelDecl()
@ (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl()
@ lldb_private::ASTResultSynthesizer::HandleTopLevelDecl()
@ clang::ParseAST()
@ lldb_private::ClangExpressionParser::ParseInternal()
@ lldb_private::ClangUserExpression::TryParse()
@ lldb_private::ClangUserExpression::Parse()
@ lldb_private::UserExpression::Evaluate()
@ lldb_private::Target::EvaluateExpression()
@ lldb_private::CommandObjectExpression::EvaluateExpression()
@ lldb_private::CommandObjectExpression::DoExecute()
@ lldb_private::CommandObjectRaw::Execute()
@ lldb_private::CommandInterpreter::HandleCommand()
@ lldb_private::CommandInterpreter::IOHandlerInputComplete()
@ lldb_private::IOHandlerEditline::Run()
@ lldb_private::Debugger::RunIOHandlers()
@ lldb_private::CommandInterpreter::RunCommandInterpreter()
@ lldb::SBDebugger::RunCommandInterpreter()
@ Driver::MainLoop()
@ main
@ __libc_start_main
@ _start
PLEASE submit a bug report to http://go/llvm-crash-bug and include the crash backtrace.
Stack dump:
0. Program arguments: llvm/llvm-project/lldb/lldb /tmp/debugging-example --one-line run --one-line "expr __promise" /tmp/debugging-example
1. HandleCommand(command = "expr __promise")
2. <eof> parser at end of file
3. <lldb wrapper prefix>:43:1: Generating code for declaration '$__lldb_expr'