Skip to content

[Flang] Assertion `actual.isProcedure()' failed. #102733

Open
@k-arrows

Description

@k-arrows

Crash itself is reproducible on Godbolt:
https://godbolt.org/z/97E1E7da5

Reproducer:

module m
  contains
    function f(i) result(res)
      character(len=i) :: res
    end function
end

subroutine s()
  use m
  procedure(f), pointer :: p

  contains
    subroutine ss()
      call sss(p)
    end subroutine
    subroutine sss(p)
      procedure(f), pointer :: p
    end subroutine
end

Stack dump:

/app/example.f90:3:14: warning: Function result is never defined
      function f(i) result(res)
               ^
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-20240810/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 -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20240810/lib/clang/20 -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
 #0 0x00000000035514d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x35514d8)
 #1 0x000000000354ee7c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007bba9c642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000000004ea6d80 fir::dyn_cast_ptrEleTy(mlir::Type) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x4ea6d80)
 #4 0x0000000003993cfc Fortran::lower::genCallOpAndResult(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::lower::SymMap&, Fortran::lower::StatementContext&, Fortran::lower::CallerInterface&, mlir::FunctionType, std::optional<mlir::Type>, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x3993cfc)
 #5 0x00000000039963e7 genUserCall(llvm::SmallVector<std::optional<Fortran::lower::PreparedActualArgument>, 1u>&, Fortran::lower::CallerInterface&, mlir::FunctionType, (anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
 #6 0x000000000399be6e genProcedureRef((anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
 #7 0x000000000399de94 Fortran::lower::convertCallToHLFIR(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>, Fortran::lower::SymMap&, Fortran::lower::StatementContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x399de94)
 #8 0x000000000396de9b (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) (.constprop.0) Bridge.cpp:0:0
 #9 0x00000000039723fc (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#10 0x000000000397285b (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#11 0x000000000397422c Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x397422c)
#12 0x00000000038d9ae1 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x38d9ae1)
#13 0x00000000035a7f15 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x35a7f15)
#14 0x0000000003597ba7 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x3597ba7)
#15 0x00000000035adf5d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x35adf5d)
#16 0x0000000001c6f808 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x1c6f808)
#17 0x0000000001b5189c main (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x1b5189c)
#18 0x00007bba9c629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#19 0x00007bba9c629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#20 0x0000000001c6e76e _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x1c6e76e)
flang-new: error: unable to execute command: Segmentation fault (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 20.0.0git (https://github.com/llvm/llvm-project.git 51a3bc12176ab46f3d2ce6ad4aa26af088d3cf14)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin

With assertion-enabled flang-new, compiling the above reproducer results in the following assertion failure:

flang-new: /path_to_llvm_project/llvm-project/flang/lib/Lower/ConvertCall.cpp:1458: (anonymous namespace)::PreparedDummyArgument prepareProcedurePointerActualArgument(mlir::Location, fir::FirOpBuilder &, const Fortran::lower::PreparedActualArgument &, mlir::Type, const Fortran::lower::CallerInterface::PassedEntity &, (anonymous namespace)::CallContext &): Assertion `actual.isProcedure()' failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcrashPrefer [crash-on-valid] or [crash-on-invalid]flang:ir

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions