Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
k-arrows opened this issue Aug 10, 2024 · 2 comments
Open

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

k-arrows opened this issue Aug 10, 2024 · 2 comments
Labels
bug Indicates an unexpected problem or unintended behavior crash Prefer [crash-on-valid] or [crash-on-invalid] flang:ir

Comments

@k-arrows
Copy link

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.
@github-actions github-actions bot added the flang Flang issues not falling into any other category label Aug 10, 2024
@k-arrows k-arrows added flang:ir crash Prefer [crash-on-valid] or [crash-on-invalid] and removed flang Flang issues not falling into any other category labels Aug 10, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 10, 2024

@llvm/issue-subscribers-flang-ir

Author: None (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&amp;, 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&amp;, Fortran::lower::SymMap&amp;, Fortran::lower::StatementContext&amp;, Fortran::lower::CallerInterface&amp;, mlir::FunctionType, std::optional&lt;mlir::Type&gt;, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x3993cfc)
 #<!-- -->5 0x00000000039963e7 genUserCall(llvm::SmallVector&lt;std::optional&lt;Fortran::lower::PreparedActualArgument&gt;, 1u&gt;&amp;, Fortran::lower::CallerInterface&amp;, mlir::FunctionType, (anonymous namespace)::CallContext&amp;) ConvertCall.cpp:0:0
 #<!-- -->6 0x000000000399be6e genProcedureRef((anonymous namespace)::CallContext&amp;) ConvertCall.cpp:0:0
 #<!-- -->7 0x000000000399de94 Fortran::lower::convertCallToHLFIR(mlir::Location, Fortran::lower::AbstractConverter&amp;, Fortran::evaluate::ProcedureRef const&amp;, std::optional&lt;mlir::Type&gt;, Fortran::lower::SymMap&amp;, Fortran::lower::StatementContext&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x399de94)
 #<!-- -->8 0x000000000396de9b (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&amp;, bool) (.constprop.0) Bridge.cpp:0:0
 #<!-- -->9 0x00000000039723fc (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&amp;) Bridge.cpp:0:0
#<!-- -->10 0x000000000397285b (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&amp;) Bridge.cpp:0:0
#<!-- -->11 0x000000000397422c Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&amp;, Fortran::semantics::SemanticsContext const&amp;) (/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&amp;, Fortran::frontend::FrontendInputFile const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x35a7f15)
#<!-- -->14 0x0000000003597ba7 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&amp;) (/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&lt;char const*&gt;, 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 &amp;, const Fortran::lower::PreparedActualArgument &amp;, mlir::Type, const Fortran::lower::CallerInterface::PassedEntity &amp;, (anonymous namespace)::CallContext &amp;): Assertion `actual.isProcedure()' failed.

@psteinfeld psteinfeld added the bug Indicates an unexpected problem or unintended behavior label Aug 11, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 11, 2024

@llvm/issue-subscribers-bug

Author: None (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&amp;, 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&amp;, Fortran::lower::SymMap&amp;, Fortran::lower::StatementContext&amp;, Fortran::lower::CallerInterface&amp;, mlir::FunctionType, std::optional&lt;mlir::Type&gt;, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x3993cfc)
 #<!-- -->5 0x00000000039963e7 genUserCall(llvm::SmallVector&lt;std::optional&lt;Fortran::lower::PreparedActualArgument&gt;, 1u&gt;&amp;, Fortran::lower::CallerInterface&amp;, mlir::FunctionType, (anonymous namespace)::CallContext&amp;) ConvertCall.cpp:0:0
 #<!-- -->6 0x000000000399be6e genProcedureRef((anonymous namespace)::CallContext&amp;) ConvertCall.cpp:0:0
 #<!-- -->7 0x000000000399de94 Fortran::lower::convertCallToHLFIR(mlir::Location, Fortran::lower::AbstractConverter&amp;, Fortran::evaluate::ProcedureRef const&amp;, std::optional&lt;mlir::Type&gt;, Fortran::lower::SymMap&amp;, Fortran::lower::StatementContext&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x399de94)
 #<!-- -->8 0x000000000396de9b (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&amp;, bool) (.constprop.0) Bridge.cpp:0:0
 #<!-- -->9 0x00000000039723fc (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&amp;) Bridge.cpp:0:0
#<!-- -->10 0x000000000397285b (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&amp;) Bridge.cpp:0:0
#<!-- -->11 0x000000000397422c Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&amp;, Fortran::semantics::SemanticsContext const&amp;) (/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&amp;, Fortran::frontend::FrontendInputFile const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240810/bin/flang-new+0x35a7f15)
#<!-- -->14 0x0000000003597ba7 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&amp;) (/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&lt;char const*&gt;, 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 &amp;, const Fortran::lower::PreparedActualArgument &amp;, mlir::Type, const Fortran::lower::CallerInterface::PassedEntity &amp;, (anonymous namespace)::CallContext &amp;): Assertion `actual.isProcedure()' failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior crash Prefer [crash-on-valid] or [crash-on-invalid] flang:ir
Projects
None yet
Development

No branches or pull requests

3 participants