Issue 91845
Summary [Flang] llvm-project/flang/lib/Lower/CallInterface.cpp:541: Fortran::evaluate::characteristics::Procedure Fortran::lower::CalleeInterface::characterize() const: Assertion `characteristic && "Fail to get characteristic from symbol"' failed.
Labels flang
Assignees
Reporter k-arrows
    Crash itself is reproducible on Godbolt:
https://godbolt.org/z/7vWE6o8ab

With assertion-enabled flang-new, the following assertion failure was observed.
```txt
flang-new: /path_to_llvm_project/llvm-project/flang/lib/Lower/CallInterface.cpp:541: Fortran::evaluate::characteristics::Procedure Fortran::lower::CalleeInterface::characterize() const: Assertion `characteristic && "Fail to get characteristic from symbol"' failed.
```

Reproducer:
```console
$ cat test.f90
module m
    contains
        subroutine s1(a1)
            procedure(s2) :: a1
        end subroutine
        subroutine s2(a2)
 procedure(s1) :: a2
        end subroutine
end module
```

Stack dump from Godbolt:
```console
terminate called after throwing an instance of 'std::bad_alloc'
  what(): std::bad_alloc
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-20240511/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-20240511/lib/clang/19 -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
 #0 0x0000000003796638 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x3796638)
 #1 0x0000000003793fac SignalHandler(int) Signals.cpp:0:0
 #2 0x000075af93242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000075af932969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x000075af93242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x000075af932287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x000075af93773bfd (/opt/compiler-explorer/gcc-snapshot/lib64/libstdc++.so.6+0xadbfd)
 #7 0x000075af93784f7a (/opt/compiler-explorer/gcc-snapshot/lib64/libstdc++.so.6+0xbef7a)
 #8 0x000075af937737a9 std::unexpected() (/opt/compiler-explorer/gcc-snapshot/lib64/libstdc++.so.6+0xad7a9)
 #9 0x000075af937851f7 (/opt/compiler-explorer/gcc-snapshot/lib64/libstdc++.so.6+0xbf1f7)
#10 0x000075af93776229 std::__throw_bad_array_new_length() (/opt/compiler-explorer/gcc-snapshot/lib64/libstdc++.so.6+0xb0229)
#11 0x00000000043879c1 (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x43879c1)
#12 0x000000000438a0f7 Fortran::evaluate::characteristics::Procedure::Procedure(Fortran::evaluate::characteristics::Procedure const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x438a0f7)
#13 0x0000000003bacc8b Fortran::lower::CalleeInterface::characterize() const (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x3bacc8b)
#14 0x0000000003bb6b78 Fortran::lower::CallInterface<Fortran::lower::CalleeInterface>::declare() (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x3bb6b78)
#15 0x0000000003b6cfeb (anonymous namespace)::FirConverter::declareFunction(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#16 0x0000000003b71836 std::__detail::__variant::__gen_vtable_impl<true, std::__detail::__variant::_Multi_array<void (*)(Fortran::common::visitors<(anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda'(Fortran::lower::pft::FunctionLikeUnit&), (anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda0'(Fortran::lower::pft::ModuleLikeUnit&), (anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda1'(Fortran::lower::pft::BlockDataUnit&), (anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda2'(Fortran::lower::pft::CompilerDirectiveUnit&), (anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda3'(Fortran::lower::pft::OpenACCDirectiveUnit&)>&&, std::variant<Fortran::lower::pft::FunctionLikeUnit, Fortran::lower::pft::ModuleLikeUnit, Fortran::lower::pft::BlockDataUnit, Fortran::lower::pft::CompilerDirectiveUnit, Fortran::lower::pft::OpenACCDirectiveUnit>&)>, std::tuple<std::variant<Fortran::lower::pft::FunctionLikeUnit, Fortran::lower::pft::ModuleLikeUnit, Fortran::lower::pft::BlockDataUnit, Fortran::lower::pft::CompilerDirectiveUnit, Fortran::lower::pft::OpenACCDirectiveUnit>&>, std::integer_sequence<unsigned long, 1ul>>::__visit_invoke(Fortran::common::visitors<(anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda'(Fortran::lower::pft::FunctionLikeUnit&), (anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda0'(Fortran::lower::pft::ModuleLikeUnit&), (anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda1'(Fortran::lower::pft::BlockDataUnit&), (anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda2'(Fortran::lower::pft::CompilerDirectiveUnit&), (anonymous namespace)::FirConverter::run(Fortran::lower::pft::Program&)::'lambda3'(Fortran::lower::pft::OpenACCDirectiveUnit&)>&&, std::variant<Fortran::lower::pft::FunctionLikeUnit, Fortran::lower::pft::ModuleLikeUnit, Fortran::lower::pft::BlockDataUnit, Fortran::lower::pft::CompilerDirectiveUnit, Fortran::lower::pft::OpenACCDirectiveUnit>&) Bridge.cpp:0:0
#17 0x0000000003b832d5 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x3b832d5)
#18 0x0000000003b15039 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x3b15039)
#19 0x00000000037e7125 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x37e7125)
#20 0x00000000037d6b37 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x37d6b37)
#21 0x00000000037ed16d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x37ed16d)
#22 0x0000000001f3f798 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x1f3f798)
#23 0x0000000001e2db04 main (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x1e2db04)
#24 0x000075af93229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x000075af93229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x0000000001f3e6fe _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin/flang-new+0x1f3e6fe)
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 504cf554639360525c3f746e7296a242350b2af9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240511/bin
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to