Issue 102985
Summary [Flang] Assertion `fir::isCharacterProcedureTuple(actual.getType()) && mlir::isa<fir::BoxProcType>(dummyType) && "unsupported dummy procedure mismatch with the actual argument"' failed.
Labels mlir, flang
Assignees
Reporter k-arrows
    Crash itself is reproducible on Godbolt:
https://godbolt.org/z/EsWdjonnE

Reproducer:
```f90
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) :: p
    end subroutine
end
```

The above reproducer is a slight modification of the one in https://github.com/llvm/llvm-project/issues/102733.

Stack dump:
```console
/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.
 #0 0x0000000003553d08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x3553d08)
 #1 0x00000000035516ac SignalHandler(int) Signals.cpp:0:0
 #2 0x000078b91b042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000000007ddb616 mlir::AsmPrinter::Impl::printDialectType(mlir::Type) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7ddb616)
 #4 0x0000000007ded871 mlir::AsmPrinter::Impl::printTypeImpl(mlir::Type) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7ded871)
 #5 0x0000000007dee31b mlir::AsmPrinter::Impl::printType(mlir::Type) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7dee31b)
 #6 0x0000000007dda324 mlir::OpAsmPrinter::printFunctionalType(mlir::Operation*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7dda324)
 #7 0x0000000007df00eb (anonymous namespace)::OperationPrinter::printGenericOp(mlir::Operation*, bool) AsmPrinter.cpp:0:0
 #8 0x0000000007df062a (anonymous namespace)::OperationPrinter::printCustomOrGenericOp(mlir::Operation*) AsmPrinter.cpp:0:0
 #9 0x0000000007df0af9 (anonymous namespace)::OperationPrinter::printFullOpWithIndentAndLoc(mlir::Operation*) AsmPrinter.cpp:0:0
#10 0x0000000007df5045 mlir::Operation::print(llvm::raw_ostream&, mlir::AsmState&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7df5045)
#11 0x0000000007df6b4a mlir::Operation::print(llvm::raw_ostream&, mlir::OpPrintingFlags const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7df6b4a)
#12 0x0000000007e5bbc4 mlir::Diagnostic::appendOp(mlir::Operation&, mlir::OpPrintingFlags const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7e5bbc4)
#13 0x0000000007ea746d mlir::Operation::emitOpError(llvm::Twine const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7ea746d)
#14 0x0000000004e58c99 fir::__mlir_ods_local_type_constraint_FIROps32(mlir::Operation*, mlir::Type, llvm::StringRef, unsigned int) FIROps.cpp:0:0
#15 0x0000000004e5f782 fir::ExtractValueOp::verifyInvariantsImpl() (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x4e5f782)
#16 0x0000000004dedc43 mlir::Op<fir::ExtractValueOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::Type>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::OneOperand, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::MemoryEffectOpInterface::Trait>::verifyInvariants(mlir::Operation*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x4dedc43)
#17 0x0000000004e0cdb0 mlir::RegisteredOperationName::Model<fir::ExtractValueOp>::verifyInvariants(mlir::Operation*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x4e0cdb0)
#18 0x0000000007ed5372 (anonymous namespace)::OperationVerifier::verifyOnEntrance(mlir::Operation&) (.isra.0) Verifier.cpp:0:0
#19 0x0000000007ed5d25 (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#20 0x0000000007ed7738 std::_Function_handler<void (), llvm::LogicalResult mlir::failableParallelForEach<mlir::Operation**, (anonymous namespace)::OperationVerifier::verifyOnExit(mlir::Operation&)::'lambda'(mlir::Operation*)>(mlir::MLIRContext*, mlir::Operation**, mlir::Operation**, (anonymous namespace)::OperationVerifier::verifyOnExit(mlir::Operation&)::'lambda'(mlir::Operation*)&&)::'lambda'()>::_M_invoke(std::_Any_data const&) Verifier.cpp:0:0
#21 0x000000000698ac2e std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>>::_M_invoke(std::_Any_data const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x698ac2e)
#22 0x000000000698b2cb std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x698b2cb)
#23 0x000078b91b099ee8 (/lib/x86_64-linux-gnu/libc.so.6+0x99ee8)
#24 0x000000000698af41 std::__future_base::_Deferred_state<std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>::_M_complete_async() (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x698af41)
#25 0x000000000698acbf std::_Function_handler<void (), std::shared_future<void> llvm::ThreadPoolInterface::asyncImpl<void>(std::function<void ()>, llvm::ThreadPoolTaskGroup*)::'lambda'()>::_M_invoke(std::_Any_data const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x698acbf)
#26 0x0000000007f2fb23 llvm::StdThreadPool::processTasks(llvm::ThreadPoolTaskGroup*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin/flang-new+0x7f2fb23)
#27 0x0000000007f3064c void* llvm::thread::ThreadProxy<std::tuple<llvm::StdThreadPool::grow(int)::'lambda'()>>(void*) ThreadPool.cpp:0:0
#28 0x000078b91b094ac3 (/lib/x86_64-linux-gnu/libc.so.6+0x94ac3)
#29 0x000078b91b126850 (/lib/x86_64-linux-gnu/libc.so.6+0x126850)
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 e2f9c1853349a5dc86ccd0e85e09af245c418aa8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240812/bin
```

With assertion-enabled flang-new, compiling the above reproducer results in the following assertion failure:
```txt
flang-new: /path_to_llvm_project/llvm-project/flang/lib/Lower/ConvertCall.cpp:1082: hlfir::Entity fixProcedureDummyMismatch(mlir::Location, fir::FirOpBuilder &, hlfir::Entity, mlir::Type): Assertion `fir::isCharacterProcedureTuple(actual.getType()) && mlir::isa<fir::BoxProcType>(dummyType) && "unsupported dummy procedure mismatch with the actual argument"' failed.
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to