Issue 143510
Summary [Flang] fatal internal error: nullptr dereference at /root/llvm-project/flang/lib/Semantics/tools.cpp(358)
Labels crash-on-invalid, flang:frontend
Assignees
Reporter k-arrows
    Compiling the following invalid program results in fatal internal error.
https://godbolt.org/z/4oo8EYcq6
```f90
module m
  real, target :: r
  pointer(p, r)
end module m

use m, rr => r
print *, rr
end
```

Backtrace:
```console
fatal internal error: nullptr dereference at /root/llvm-project/flang/lib/Semantics/tools.cpp(358)
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-20250610/bin/flang -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 -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20250610/lib/clang/21 -mframe-pointer=all -o /app/output.s -x f95 /app/example.f90
 #0 0x0000000003eb6618 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x3eb6618)
 #1 0x0000000003eb41d4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x0000778d37a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000778d37a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000778d37a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x0000778d37a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000005bb67a9 (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x5bb67a9)
 #7 0x0000000004a3a968 Fortran::semantics::GetCrayPointer(Fortran::semantics::Symbol const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x4a3a968)
 #8 0x0000000004563531 (anonymous namespace)::HlfirDesignatorBuilder::gen(Fortran::common::Reference<Fortran::semantics::Symbol const> const&) ConvertExprToHLFIR.cpp:0:0
 #9 0x000000000458a7ad hlfir::EntityWithAttributes Fortran::common::log2visit::Log2VisitHelper<0ul, 4ul, hlfir::EntityWithAttributes, (anonymous namespace)::HlfirDesignatorBuilder::gen(std::variant<Fortran::common::Reference<Fortran::semantics::Symbol const>, Fortran::evaluate::Component, Fortran::evaluate::ArrayRef, Fortran::evaluate::CoarrayRef, Fortran::evaluate::ComplexPart> const&, bool)::'lambda'(auto const&), std::variant<Fortran::common::Reference<Fortran::semantics::Symbol const>, Fortran::evaluate::Component, Fortran::evaluate::ArrayRef, Fortran::evaluate::CoarrayRef, Fortran::evaluate::ComplexPart> const&>((anonymous namespace)::HlfirDesignatorBuilder::gen(std::variant<Fortran::common::Reference<Fortran::semantics::Symbol const>, Fortran::evaluate::Component, Fortran::evaluate::ArrayRef, Fortran::evaluate::CoarrayRef, Fortran::evaluate::ComplexPart> const&, bool)::'lambda'(auto const&)&&, unsigned long, std::variant<Fortran::common::Reference<Fortran::semantics::Symbol const>, Fortran::evaluate::Component, Fortran::evaluate::ArrayRef, Fortran::evaluate::CoarrayRef, Fortran::evaluate::ComplexPart> const&) ConvertExprToHLFIR.cpp:0:0
#10 0x000000000459dd1c hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::Type<(Fortran::common::TypeCategory)2, 4>>(Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)2, 4>> const&) ConvertExprToHLFIR.cpp:0:0
#11 0x000000000457d74b hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)2>>(Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)2>> const&) ConvertExprToHLFIR.cpp:0:0
#12 0x00000000045b8d8f hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeType>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (.part.0) ConvertExprToHLFIR.cpp:0:0
#13 0x00000000045b9185 Fortran::lower::convertExprToValue(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::SymMap&, Fortran::lower::StatementContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x45b9185)
#14 0x00000000043096d5 (anonymous namespace)::FirConverter::genExprValue(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::StatementContext&, mlir::Location*) Bridge.cpp:0:0
#15 0x000000000461ca8b genOutputItemList(Fortran::lower::AbstractConverter&, mlir::Value, std::__cxx11::list<Fortran::parser::OutputItem, std::allocator<Fortran::parser::OutputItem>> const&, bool, bool, mlir::Value&, bool) IO.cpp:0:0
#16 0x0000000004623386 mlir::Value genDataTransferStmt<false, false, Fortran::parser::PrintStmt>(Fortran::lower::AbstractConverter&, Fortran::parser::PrintStmt const&) IO.cpp:0:0
#17 0x00000000043427cb (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) (.constprop.0) Bridge.cpp:0:0
#18 0x000000000434629c (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#19 0x0000000004348414 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x4348414)
#20 0x00000000041c1466 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x41c1466)
#21 0x0000000003f0dca5 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x3f0dca5)
#22 0x0000000003efc757 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x3efc757)
#23 0x0000000003f17613 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x3f17613)
#24 0x0000000002209eca fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x2209eca)
#25 0x00000000020bfbc6 main (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x20bfbc6)
#26 0x0000778d37a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#27 0x0000778d37a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#28 0x0000000002208895 _start (/opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin/flang+0x2208895)
flang-21: error: unable to execute command: Aborted (core dumped)
flang-21: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 21.0.0git (https://github.com/llvm/llvm-project.git 3e6a704b5fe33aa0e25cc482199985368a8ee6cf)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20250610/bin
flang-21: note: diagnostic msg: 
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to