| Issue |
175293
|
| Summary |
[clang][bytecode] Assertion `NumElems <= (MaxArrayElemBytes / ElemSize)' failed.
|
| Labels |
crash-on-valid,
clang:bytecode
|
| Assignees |
|
| Reporter |
k-arrows
|
Reproducer:
https://godbolt.org/z/571df7cen
```cpp
char q[-2U];
void foo() { char *p = q + 1; }
```
Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ByteCode/Descriptor.cpp:308: clang::interp::Descriptor::Descriptor(const DeclTy&, clang::interp::PrimType, clang::interp::Descriptor::MetadataSize, size_t, bool, bool, bool): Assertion `NumElems <= (MaxArrayElemBytes / ElemSize)' 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>:3:29: current parser token ';'
2. <source>:3:12: parsing function body 'foo'
3. <source>:3:12: in compound statement ('{}')
#0 0x0000000004308bd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4308bd8)
#1 0x0000000004306004 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4306004)
#2 0x0000000004248d58 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000747a3ca42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000747a3ca969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000747a3ca42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000747a3ca287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000747a3ca2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000747a3ca39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000007debede clang::interp::Descriptor::Descriptor(llvm::PointerUnion<clang::Decl const*, clang::Expr const*> const&, clang::interp::PrimType, std::optional<unsigned int>, unsigned long, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7debede)
#10 0x0000000007ff9cbc clang::interp::Program::createDescriptor(llvm::PointerUnion<clang::Decl const*, clang::Expr const*> const&, clang::Type const*, std::optional<unsigned int>, bool, bool, bool, bool, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ff9cbc)
#11 0x0000000007ffc9db clang::interp::Program::getOrCreateDummy(llvm::PointerUnion<clang::Decl const*, clang::Expr const*> const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ffc9db)
#12 0x0000000008242e1b clang::interp::Compiler<clang::interp::EvalEmitter>::emitDummyPtr(llvm::PointerUnion<clang::Decl const*, clang::Expr const*> const&, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8242e1b)
#13 0x0000000008275b5d clang::interp::Compiler<clang::interp::EvalEmitter>::visitDeclRef(clang::ValueDecl const*, clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8275b5d)
#14 0x000000000827ff6a clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x827ff6a)
#15 0x00000000082815d5 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitCastExpr(clang::CastExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x82815d5)
#16 0x000000000827ff6a clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x827ff6a)
#17 0x000000000824795d clang::interp::Compiler<clang::interp::EvalEmitter>::VisitPointerArithBinOp(clang::BinaryOperator const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x824795d)
#18 0x0000000008283094 clang::interp::Compiler<clang::interp::EvalEmitter>::VisitBinaryOperator(clang::BinaryOperator const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8283094)
#19 0x000000000827ff6a clang::interp::Compiler<clang::interp::EvalEmitter>::visit(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x827ff6a)
#20 0x0000000008274136 clang::interp::Compiler<clang::interp::EvalEmitter>::visitExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8274136)
#21 0x0000000007df0bdd clang::interp::EvalEmitter::interpretExpr(clang::Expr const*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7df0bdd)
#22 0x0000000007de0ea3 clang::interp::Context::evaluateAsRValue(clang::interp::State&, clang::Expr const*, clang::APValue&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7de0ea3)
#23 0x0000000007d45dc3 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#24 0x0000000007d4a33e clang::Expr::EvaluateForOverflow(clang::ASTContext const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7d4a33e)
#25 0x0000000006c8bfd6 clang::Sema::CheckForIntOverflow(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c8bfd6)
#26 0x0000000006cd330c clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cd330c)
#27 0x000000000707b527 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x707b527)
#28 0x0000000006e385d5 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e385d5)
#29 0x0000000006a86911 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a86911)
#30 0x0000000006a93b3a 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+++0x6a93b3a)
#31 0x0000000006a9c84f clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a9c84f)
#32 0x0000000006a9cd1c clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a9cd1c)
#33 0x0000000006b4e264 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+++0x6b4e264)
#34 0x0000000006b4eaf6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b4eaf6)
#35 0x0000000006b5743e clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b5743e)
#36 0x0000000006b57c8a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b57c8a)
#37 0x0000000006a5e0db clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a5e0db)
#38 0x0000000006a9454d 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+++0x6a9454d)
#39 0x0000000006a5123b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a5123b)
#40 0x0000000006a51a2f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a51a2f)
#41 0x0000000006a5985a clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a5985a)
#42 0x0000000006a5a7f5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a5a7f5)
#43 0x0000000006a3b87a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a3b87a)
#44 0x0000000004c6ae28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c6ae28)
#45 0x0000000004f64215 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f64215)
#46 0x0000000004ee404e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ee404e)
#47 0x000000000505e8bd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x505e8bd)
#48 0x0000000000de879e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xde879e)
#49 0x0000000000ddf16a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#50 0x0000000000ddf2ed 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
#51 0x0000000004cdde69 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
#52 0x00000000042491f4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42491f4)
#53 0x0000000004cde47f 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
#54 0x0000000004c9ee12 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c9ee12)
#55 0x0000000004c9fdbe 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+++0x4c9fdbe)
#56 0x0000000004ca7215 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ca7215)
#57 0x0000000000de4b11 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xde4b11)
#58 0x0000000000c8ee04 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc8ee04)
#59 0x0000747a3ca29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#60 0x0000747a3ca29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#61 0x0000000000ddec05 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xddec05)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
Goes back to clang-19:
https://godbolt.org/z/WfYGd83ef
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs