-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang:bytecodeIssues for the clang bytecode constexpr interpreterIssues for the clang bytecode constexpr interpretercrash-on-invalid
Description
Reproducer:
https://godbolt.org/z/31vqPn67z
extern void abort(void);
struct s {
int a;
int b;
};
struct s *s0 = &(struct s){1, 2};
struct s *s1 = &(struct s){1, 2};
const struct s *s2 = &(const struct s){1, 2};
void foo(void) {
if (s0->a != 1 || s0->b != 2 || s1->a != 1 || s1->b != 2 || s2->a != 1 ||
s2->b != 2)
abort();
}Backtrace:
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ByteCode/Pointer.h:289: const clang::interp::Descriptor* clang::interp::Pointer::getDeclDesc() const: Assertion `BS.Pointee' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fexperimental-new-constant-interpreter <source>
1. <source>:14:17: current parser token ')'
2. <source>:12:16: parsing function body 'foo'
3. <source>:12:16: in compound statement ('{}')
#0 0x0000000004260d08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4260d08)
#1 0x000000000425e134 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x425e134)
#2 0x00000000041a2398 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007012aba42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007012aba969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007012aba42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007012aba287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007012aba2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007012aba39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000007e645af clang::interp::Pointer::getFieldDesc() const (.part.0) Interp.cpp:0:0
#10 0x0000000007e64b6d clang::interp::CheckRange(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Pointer const&, clang::CheckSubobjectKind) (.constprop.0) Interp.cpp:0:0
#11 0x0000000007e72d99 clang::interp::getField(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Pointer const&, unsigned int) Interp.cpp:0:0
#12 0x0000000007e73079 clang::interp::GetPtrFieldPop(clang::interp::InterpState&, clang::interp::CodePtr, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7e73079)
#13 0x000000000814e477 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitMemberExpr(clang::MemberExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x814e477)
#14 0x0000000008153e7a clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8153e7a)
#15 0x0000000008155663 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitCastExpr(clang::CastExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8155663)
#16 0x0000000008153e7a clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8153e7a)
#17 0x0000000008148a66 clang::interp::Compiler<clang::interp::EvalEmitter>::visitExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8148a66)
#18 0x0000000007ccd09d clang::interp::EvalEmitter::interpretExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ccd09d)
#19 0x0000000007cbc583 clang::interp::Context::evaluateAsRValue(clang::interp::State&, clang::Expr const*, clang::APValue&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7cbc583)
#20 0x0000000007c25ef3 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#21 0x0000000007c29f3f clang::Expr::isCXX11ConstantExpr(clang::ASTContext const&, clang::APValue*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7c29f3f)
#22 0x0000000007c2a400 EvaluateCPlusPlus11IntegralConstantExpr(clang::ASTContext const&, clang::Expr const*, llvm::APSInt*) ExprConstant.cpp:0:0
#23 0x0000000007c2cacf clang::Expr::getIntegerConstantExpr(clang::ASTContext const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7c2cacf)
#24 0x0000000006bf5997 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) (.constprop.0) SemaChecking.cpp:0:0
#25 0x0000000006bf65d5 clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6bf65d5)
#26 0x0000000006f98dc7 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f98dc7)
#27 0x0000000006ee6100 clang::Sema::ActOnCondition(clang::Scope*, clang::SourceLocation, clang::Expr*, clang::Sema::ConditionKind, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ee6100)
#28 0x0000000006a06e3c clang::Parser::ParseCXXCondition(clang::ActionResult<clang::Stmt*, true>*, clang::SourceLocation, clang::Sema::ConditionKind, bool, clang::Parser::ForRangeInfo*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a06e3c)
#29 0x0000000006a6f6db clang::Parser::ParseParenExprOrCondition(clang::ActionResult<clang::Stmt*, true>*, clang::Sema::ConditionResult&, clang::SourceLocation, clang::Sema::ConditionKind, clang::SourceLocation&, clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a6f6db)
#30 0x0000000006a744f6 clang::Parser::ParseIfStatement(clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a744f6)
#31 0x0000000006a71f0a clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a71f0a)
#32 0x0000000006a72f16 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a72f16)
#33 0x0000000006a7b69e clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a7b69e)
#34 0x0000000006a7beea clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a7beea)
#35 0x0000000006981f4b clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6981f4b)
#36 0x00000000069b836d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69b836d)
#37 0x00000000069756fe clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69756fe)
#38 0x0000000006975e9f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6975e9f)
#39 0x000000000697d753 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x697d753)
#40 0x000000000697e665 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x697e665)
#41 0x000000000695fc5a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x695fc5a)
#42 0x0000000004badf38 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4badf38)
#43 0x0000000004e9aff5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e9aff5)
#44 0x0000000004e1be2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e1be2e)
#45 0x0000000004f9313d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f9313d)
#46 0x0000000000dd2780 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdd2780)
#47 0x0000000000dc92fa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#48 0x0000000000dc947d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#49 0x0000000004c17ab9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#50 0x00000000041a2834 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41a2834)
#51 0x0000000004c180cf clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#52 0x0000000004bd8e22 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bd8e22)
#53 0x0000000004bd9dce clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bd9dce)
#54 0x0000000004be1525 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4be1525)
#55 0x0000000000dceca1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdceca1)
#56 0x0000000000c7d434 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc7d434)
#57 0x00007012aba29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#58 0x00007012aba29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#59 0x0000000000dc8d95 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdc8d95)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134Metadata
Metadata
Assignees
Labels
clang:bytecodeIssues for the clang bytecode constexpr interpreterIssues for the clang bytecode constexpr interpretercrash-on-invalid