[clang] [clang][bytecode] Allocate IntegralAP and Floating types using an allocator (PR #144246)

David Spickett via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 19 08:36:05 PDT 2025


Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/144246 at github.com>


DavidSpickett wrote:

This only reproduces if we build it with clang (19.1.7, but might not be version specific). I added a debug trap in place of the assert and got a better traceback:
```
-- Testing: 1 tests, 1 workers --
FAIL: Clang :: AST/ByteCode/intap.cpp (1 of 1)
******************** TEST 'Clang :: AST/ByteCode/intap.cpp' FAILED ********************
Exit Code: 133

Command Output (stderr):
--
/home/david.spickett/build-llvm-arm/bin/clang -cc1 -internal-isystem /home/david.spickett/build-llvm-arm/lib/clang/21/include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify=expected,both /home/david.spickett/llvm-project/clang/test/AST/ByteCode/intap.cpp # RUN: at line 1
+ /home/david.spickett/build-llvm-arm/bin/clang -cc1 -internal-isystem /home/david.spickett/build-llvm-arm/lib/clang/21/include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify=expected,both /home/david.spickett/llvm-project/clang/test/AST/ByteCode/intap.cpp
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: /home/david.spickett/build-llvm-arm/bin/clang -cc1 -internal-isystem /home/david.spickett/build-llvm-arm/lib/clang/21/include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify=expected,both /home/david.spickett/llvm-project/clang/test/AST/ByteCode/intap.cpp
1.	/home/david.spickett/llvm-project/clang/test/AST/ByteCode/intap.cpp:28:35: current parser token ';'
 #0 0x024a15b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/david.spickett/build-llvm-arm/bin/clang+0x1b535b8)
 #1 0x0249edfc llvm::sys::RunSignalHandlers() (/home/david.spickett/build-llvm-arm/bin/clang+0x1b50dfc)
 #2 0x024a203c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0xf7b1d6f0 __default_rt_sa_restorer ./signal/../sysdeps/unix/sysv/linux/arm/sigrestorer.S:80:0
 #4 0x013a0f08 llvm::APInt::APInt(unsigned int, unsigned long long, bool, bool) (/home/david.spickett/build-llvm-arm/bin/clang+0xa52f08)
 #5 0x056644e0 clang::interp::IntegralAP<true>::toAPSInt(unsigned int) const (/home/david.spickett/build-llvm-arm/bin/clang+0x4d164e0)
 #6 0x0562df08 bool clang::interp::EvalEmitter::emitRet<(clang::interp::PrimType)9>(clang::interp::SourceInfo const&) (/home/david.spickett/build-llvm-arm/bin/clang+0x4cdff08)
 #7 0x0598b3a0 clang::interp::Compiler<clang::interp::EvalEmitter>::visitDeclAndReturn(clang::VarDecl const*, bool) (/home/david.spickett/build-llvm-arm/bin/clang+0x503d3a0)
 #8 0x05593398 clang::interp::EvalEmitter::interpretDecl(clang::VarDecl const*, bool) (/home/david.spickett/build-llvm-arm/bin/clang+0x4c45398)
 #9 0x0558add0 clang::interp::Context::evaluateAsInitializer(clang::interp::State&, clang::VarDecl const*, clang::APValue&) (/home/david.spickett/build-llvm-arm/bin/clang+0x4c3cdd0)
#10 0x054aeebc clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/home/david.spickett/build-llvm-arm/bin/clang+0x4b60ebc)
#11 0x0537e7c4 clang::VarDecl::evaluateValueImpl(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&, bool) const (/home/david.spickett/build-llvm-arm/bin/clang+0x4a307c4)
#12 0x0537e948 clang::VarDecl::checkForConstantInitialization(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic>>&) const (/home/david.spickett/build-llvm-arm/bin/clang+0x4a30948)
#13 0x04838118 clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) (/home/david.spickett/build-llvm-arm/bin/clang+0x3eea118)
#14 0x04836b6c clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/home/david.spickett/build-llvm-arm/bin/clang+0x3ee8b6c)
#15 0x04567694 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/home/david.spickett/build-llvm-arm/bin/clang+0x3c19694)
#16 0x04563fa0 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/home/david.spickett/build-llvm-arm/bin/clang+0x3c15fa0)
#17 0x0453c540 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/home/david.spickett/build-llvm-arm/bin/clang+0x3bee540)
#18 0x0453bc14 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/home/david.spickett/build-llvm-arm/bin/clang+0x3bedc14)
#19 0x0453abf4 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/david.spickett/build-llvm-arm/bin/clang+0x3becbf4)
#20 0x04538830 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/home/david.spickett/build-llvm-arm/bin/clang+0x3bea830)
#21 0x045341b8 clang::ParseAST(clang::Sema&, bool, bool) (/home/david.spickett/build-llvm-arm/bin/clang+0x3be61b8)
#22 0x02f785c4 clang::FrontendAction::Execute() (/home/david.spickett/build-llvm-arm/bin/clang+0x262a5c4)
#23 0x02ef08ac clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/david.spickett/build-llvm-arm/bin/clang+0x25a28ac)
#24 0x0305fdd0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/david.spickett/build-llvm-arm/bin/clang+0x2711dd0)
#25 0x01257cd0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/david.spickett/build-llvm-arm/bin/clang+0x909cd0)
#26 0x01253fa8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x01252f68 clang_main(int, char**, llvm::ToolContext const&) (/home/david.spickett/build-llvm-arm/bin/clang+0x904f68)
#28 0x012630a8 main (/home/david.spickett/build-llvm-arm/bin/clang+0x9150a8)
#29 0xf7b0d7d6 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#30 0xf7b0d886 call_init ./csu/libc-start.c:128:20
#31 0xf7b0d886 __libc_start_main ./csu/libc-start.c:379:5
/home/david.spickett/build-llvm-arm/tools/clang/test/AST/ByteCode/Output/intap.cpp.script: line 4: 1330655 Trace/breakpoint trap   (core dumped) /home/david.spickett/build-llvm-arm/bin/clang -cc1 -internal-isystem /home/david.spickett/build-llvm-arm/lib/clang/21/include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify=expected,both /home/david.spickett/llvm-project/clang/test/AST/ByteCode/intap.cpp
```
So either it's a clang bug or its undefined behaviour, I bet the latter but this backtrace isn't much help.

Trying to get a debug build, proving difficult due to memory limitations.

https://github.com/llvm/llvm-project/pull/144246


More information about the cfe-commits mailing list