Skip to content

[Flang] fatal internal error: CHECK(j >= lb && j - lb < extent) failed at /root/llvm-project/flang/lib/Evaluate/constant.cpp(76) #86935

Closed
@k-arrows

Description

@k-arrows

Reproducible on Godbolt:
https://godbolt.org/z/WsejT7Ya5

Reproducer:

$ cat test.f90
real, parameter :: a(2:3) = 0.0
print *, norm2(a)
end

Stack dump:

fatal internal error: CHECK(j >= lb && j - lb < extent) failed at /root/llvm-project/flang/lib/Evaluate/constant.cpp(76)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new -fc1 -triple x86_64-unknown-linux-gnu -S -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
 #0 0x0000000003767418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x3767418)
 #1 0x0000000003764d8c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f7f6ba42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007f7f6ba969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007f7f6ba42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007f7f6ba287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000004be0609 (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x4be0609)
 #7 0x00000000043d794e Fortran::evaluate::ConstantBounds::SubscriptsToOffset(std::vector<long, std::allocator<long>> const&) const (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x43d794e)
 #8 0x00000000043de249 Fortran::evaluate::Constant<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>>::At(std::vector<long, std::allocator<long>> const&) const (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x43de249)
 #9 0x00000000046e8616 Fortran::evaluate::MaxvalMinvalAccumulator<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>, true>::operator()(Fortran::evaluate::value::Real<Fortran::evaluate::value::Integer<32, true, 32, unsigned int, unsigned long>, 24>&, std::vector<long, std::allocator<long>> const&, bool) const (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x46e8616)
#10 0x00000000046e921e Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>> Fortran::evaluate::FoldNorm2<4>(Fortran::evaluate::FoldingContext&, Fortran::evaluate::FunctionRef<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>>&&) fold-real.cpp:0:0
#11 0x000000000473b9bc Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>> Fortran::evaluate::FoldIntrinsicFunction<4>(Fortran::evaluate::FoldingContext&, Fortran::evaluate::FunctionRef<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x473b9bc)
#12 0x000000000473cf46 Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>> Fortran::evaluate::FoldOperation<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>>(Fortran::evaluate::FoldingContext&, Fortran::evaluate::FunctionRef<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x473cf46)
#13 0x000000000472e1de Fortran::evaluate::ExpressionBase<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>>::Rewrite(Fortran::evaluate::FoldingContext&, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)1, 4>>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x472e1de)
#14 0x000000000471bce8 Fortran::evaluate::ExpressionBase<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)1>>::Rewrite(Fortran::evaluate::FoldingContext&, Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)1>>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x471bce8)
#15 0x00000000044080f0 Fortran::evaluate::ExpressionBase<Fortran::evaluate::SomeType>::Rewrite(Fortran::evaluate::FoldingContext&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType>&&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x44080f0)
#16 0x0000000003fd701b std::optional<Fortran::evaluate::Expr<Fortran::evaluate::SomeType>> Fortran::evaluate::ExpressionAnalyzer::ExprOrVariable<Fortran::parser::Expr>(Fortran::parser::Expr const&, Fortran::parser::CharBlock) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x3fd701b)
#17 0x0000000003fd7d6f Fortran::evaluate::ExpressionAnalyzer::IterativelyAnalyzeSubexpressions(Fortran::parser::Expr const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x3fd7d6f)
#18 0x0000000003fd8105 Fortran::evaluate::ExpressionAnalyzer::Analyze(Fortran::parser::Expr const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x3fd8105)
#19 0x0000000003feaf6c void Fortran::parser::IterativeWalk<Fortran::parser::Expr const, Fortran::semantics::ExprChecker, Fortran::parser::Expr::IntrinsicUnary const, Fortran::parser::Expr::IntrinsicBinary const>(Fortran::parser::Expr const&, Fortran::semantics::ExprChecker&) expression.cpp:0:0
#20 0x0000000003fed050 void Fortran::parser::Walk<Fortran::parser::OutputItem, Fortran::semantics::ExprChecker>(std::__cxx11::list<Fortran::parser::OutputItem, std::allocator<Fortran::parser::OutputItem>> const&, Fortran::semantics::ExprChecker&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x3fed050)
#21 0x0000000003ff73c1 void Fortran::parser::Walk<Fortran::semantics::ExprChecker>(std::__cxx11::list<Fortran::parser::ExecutionPartConstruct, std::allocator<Fortran::parser::ExecutionPartConstruct>> const&, Fortran::semantics::ExprChecker&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x3ff73c1)
#22 0x0000000003ff885f Fortran::semantics::ExprChecker::Walk(Fortran::parser::Program const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x3ff885f)
#23 0x00000000040f979d Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x40f979d)
#24 0x00000000037ab967 Fortran::frontend::FrontendAction::runSemanticChecks() (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x37ab967)
#25 0x0000000003ad6490 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x3ad6490)
#26 0x00000000037aaf45 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x37aaf45)
#27 0x000000000379acf7 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x379acf7)
#28 0x00000000037b11cd Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x37b11cd)
#29 0x0000000001f493d8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x1f493d8)
#30 0x0000000001e4d75d main (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x1e4d75d)
#31 0x00007f7f6ba29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x00007f7f6ba29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x0000000001f4833e _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin/flang-new+0x1f4833e)
flang-new: error: unable to execute command: Aborted (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git 54a9f0e441c7cc3c954d24cfde00cb933306a9e9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240327/bin

Metadata

Metadata

Assignees

Labels

crashPrefer [crash-on-valid] or [crash-on-invalid]flang:frontend

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions