<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94884>94884</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] flang-new crashes on a program that includes a submodule
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Reproducible on Godbolt:
https://godbolt.org/z/38qrv9jxc
Reproducer:
```console
module m
interface
module subroutine s
end
end interface
end
submodule (m) sm
procedure(s), pointer :: p
contains
module procedure s
end
end
```
Stack dump:
```console
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-20240608/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-20240608/bin/.. -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
#0 0x0000000003850c68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x3850c68)
#1 0x000000000384e5dc SignalHandler(int) Signals.cpp:0:0
#2 0x00007d2049a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007d2049a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007d2049a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007d2049a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x0000000001e8f6d2 Fortran::lower::getOrDeclareFunction(Fortran::evaluate::ProcedureDesignator const&, Fortran::lower::AbstractConverter&) (.cold) CallInterface.cpp:0:0
#7 0x0000000003e96c10 (anonymous namespace)::TypeBuilderImpl::genSymbolType(Fortran::semantics::Symbol const&, bool, bool) ConvertType.cpp:0:0
#8 0x0000000003e97b26 Fortran::lower::translateVariableToFIRType(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x3e97b26)
#9 0x0000000003eaeae1 defineGlobal(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&, llvm::StringRef, mlir::StringAttr, cuf::DataAttributeAttr) ConvertVariable.cpp:0:0
#10 0x0000000003eaf88a Fortran::lower::defineModuleVariable(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x3eaf88a)
#11 0x0000000003c2d8fb std::_Function_handler<void (), (anonymous namespace)::FirConverter::lowerModuleDeclScope(Fortran::lower::pft::ModuleLikeUnit&)::'lambda'()>::_M_invoke(std::_Any_data const&) Bridge.cpp:0:0
#12 0x0000000003c2c3f6 (anonymous namespace)::FirConverter::createGlobalOutsideOfFunctionLowering(std::function<void ()> const&) Bridge.cpp:0:0
#13 0x0000000003c2c8b0 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
#14 0x0000000003c3ed55 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x3c3ed55)
#15 0x0000000003bd0daa Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x3bd0daa)
#16 0x00000000038a19d5 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x38a19d5)
#17 0x0000000003891337 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x3891337)
#18 0x00000000038a7a1d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x38a7a1d)
#19 0x0000000001fdd798 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x1fdd798)
#20 0x0000000001ec5b54 main (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x1ec5b54)
#21 0x00007d2049a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x00007d2049a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#23 0x0000000001fdc6fe _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin/flang-new+0x1fdc6fe)
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 435dd9746107e13c2ad019be3bd34815f7d2360d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240608/bin
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt9z2yoW_muUF0YeCcn68ZAH147vdqaddpruvnoQHDncINAF5Dr71--AJNty88PpNL27O-00iQTinO_7zgEkgBjDtxLgOpi_C-arK9LZO6Wv70OitfpmrirFHq6_QKsV6yivBCAl0R-KVUrYIFkE0SqIFnfWtsbd4XWA19u-dqb0NsDrfwd4nRR_6V355572j_e_R6OgD3aCLOr_UyWNEtCXNop1AlDT3yHEpQVdEwpjAULDI6artOosl4DMsRIkG29AsvPmh9r-t-mqwViAiybAJTIHx61WFFinIcCFCXAZ4CVqlbeHHIdk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