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] fatal internal error: CHECK(index < argCount) failed at /root/llvm-project/flang/lib/Evaluate/characteristics.cpp(1344) #92678

Closed
k-arrows opened this issue May 19, 2024 · 3 comments · Fixed by #92800
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior crash Prefer [crash-on-valid] or [crash-on-invalid] flang:frontend

Comments

@k-arrows
Copy link

Reproducible on Godbolt:
https://godbolt.org/z/7oz9T1bWG

Reproducer (reduced and modified from https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/abstract_type_6.f03):

$ cat test.f03
module m
type, abstract :: top
contains
   procedure :: proc_c => top_c
end type top

type, extends(top) :: bottom
contains
   procedure :: proc_c => bottom_c
end type bottom
contains

subroutine bottom_c(obj)
   class(bottom) :: obj
   call top_c(obj)
end subroutine bottom_c
end module

Stack dump:

fatal internal error: CHECK(index < argCount) failed at /root/llvm-project/flang/lib/Evaluate/characteristics.cpp(1344)
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-20240518/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-20240518/bin/.. -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
 #0 0x0000000003870558 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x3870558)
 #1 0x000000000386decc SignalHandler(int) Signals.cpp:0:0
 #2 0x00007c8aaec42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007c8aaec969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007c8aaec42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007c8aaec287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000004e468c9 (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4e468c9)
 #7 0x00000000044b991f Fortran::evaluate::characteristics::Procedure::FindPassIndex(std::optional<Fortran::parser::CharBlock>) const (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x44b991f)
 #8 0x000000000437775b Fortran::semantics::CheckHelper::CheckProcBinding(Fortran::semantics::Symbol const&, Fortran::semantics::ProcBindingDetails const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x437775b)
 #9 0x0000000004388705 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Symbol const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4388705)
#10 0x000000000438893c Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x438893c)
#11 0x00000000043889a8 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x43889a8)
#12 0x00000000043889a8 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x43889a8)
#13 0x0000000004388fed Fortran::semantics::CheckDeclarations(Fortran::semantics::SemanticsContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4388fed)
#14 0x000000000426be77 Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x426be77)
#15 0x00000000038c2005 Fortran::frontend::FrontendAction::runSemanticChecks() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c2005)
#16 0x0000000003bef85a Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x3bef85a)
#17 0x00000000038c1415 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c1415)
#18 0x00000000038b0d17 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38b0d17)
#19 0x00000000038c745d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c745d)
#20 0x0000000002020c08 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x2020c08)
#21 0x0000000001f0ede4 main (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x1f0ede4)
#22 0x00007c8aaec29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#23 0x00007c8aaec29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#24 0x000000000201fb6e _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x201fb6e)
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 881f20e958e80bd30463fc57d2d3e891bcb8a571)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin
@github-actions github-actions bot added the flang Flang issues not falling into any other category label May 19, 2024
@k-arrows k-arrows added flang:frontend crash Prefer [crash-on-valid] or [crash-on-invalid] and removed flang Flang issues not falling into any other category labels May 19, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 19, 2024

@llvm/issue-subscribers-flang-frontend

Author: None (k-arrows)

Reproducible on Godbolt: https://godbolt.org/z/7oz9T1bWG

Reproducer (reduced and modified from https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/abstract_type_6.f03):

$ cat test.f03
module m
type, abstract :: top
contains
   procedure :: proc_c =&gt; top_c
end type top

type, extends(top) :: bottom
contains
   procedure :: proc_c =&gt; bottom_c
end type bottom
contains

subroutine bottom_c(obj)
   class(bottom) :: obj
   call top_c(obj)
end subroutine bottom_c
end module

Stack dump:

fatal internal error: CHECK(index &lt; argCount) failed at /root/llvm-project/flang/lib/Evaluate/characteristics.cpp(1344)
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-20240518/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-20240518/bin/.. -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
 #<!-- -->0 0x0000000003870558 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x3870558)
 #<!-- -->1 0x000000000386decc SignalHandler(int) Signals.cpp:0:0
 #<!-- -->2 0x00007c8aaec42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->3 0x00007c8aaec969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->4 0x00007c8aaec42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->5 0x00007c8aaec287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->6 0x0000000004e468c9 (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4e468c9)
 #<!-- -->7 0x00000000044b991f Fortran::evaluate::characteristics::Procedure::FindPassIndex(std::optional&lt;Fortran::parser::CharBlock&gt;) const (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x44b991f)
 #<!-- -->8 0x000000000437775b Fortran::semantics::CheckHelper::CheckProcBinding(Fortran::semantics::Symbol const&amp;, Fortran::semantics::ProcBindingDetails const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x437775b)
 #<!-- -->9 0x0000000004388705 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Symbol const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4388705)
#<!-- -->10 0x000000000438893c Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x438893c)
#<!-- -->11 0x00000000043889a8 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x43889a8)
#<!-- -->12 0x00000000043889a8 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x43889a8)
#<!-- -->13 0x0000000004388fed Fortran::semantics::CheckDeclarations(Fortran::semantics::SemanticsContext&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4388fed)
#<!-- -->14 0x000000000426be77 Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x426be77)
#<!-- -->15 0x00000000038c2005 Fortran::frontend::FrontendAction::runSemanticChecks() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c2005)
#<!-- -->16 0x0000000003bef85a Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x3bef85a)
#<!-- -->17 0x00000000038c1415 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&amp;, Fortran::frontend::FrontendInputFile const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c1415)
#<!-- -->18 0x00000000038b0d17 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38b0d17)
#<!-- -->19 0x00000000038c745d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c745d)
#<!-- -->20 0x0000000002020c08 fc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x2020c08)
#<!-- -->21 0x0000000001f0ede4 main (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x1f0ede4)
#<!-- -->22 0x00007c8aaec29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->23 0x00007c8aaec29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->24 0x000000000201fb6e _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x201fb6e)
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 881f20e958e80bd30463fc57d2d3e891bcb8a571)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin

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

llvmbot commented May 19, 2024

@llvm/issue-subscribers-bug

Author: None (k-arrows)

Reproducible on Godbolt: https://godbolt.org/z/7oz9T1bWG

Reproducer (reduced and modified from https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/abstract_type_6.f03):

$ cat test.f03
module m
type, abstract :: top
contains
   procedure :: proc_c =&gt; top_c
end type top

type, extends(top) :: bottom
contains
   procedure :: proc_c =&gt; bottom_c
end type bottom
contains

subroutine bottom_c(obj)
   class(bottom) :: obj
   call top_c(obj)
end subroutine bottom_c
end module

Stack dump:

fatal internal error: CHECK(index &lt; argCount) failed at /root/llvm-project/flang/lib/Evaluate/characteristics.cpp(1344)
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-20240518/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-20240518/bin/.. -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
 #<!-- -->0 0x0000000003870558 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x3870558)
 #<!-- -->1 0x000000000386decc SignalHandler(int) Signals.cpp:0:0
 #<!-- -->2 0x00007c8aaec42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->3 0x00007c8aaec969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->4 0x00007c8aaec42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->5 0x00007c8aaec287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->6 0x0000000004e468c9 (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4e468c9)
 #<!-- -->7 0x00000000044b991f Fortran::evaluate::characteristics::Procedure::FindPassIndex(std::optional&lt;Fortran::parser::CharBlock&gt;) const (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x44b991f)
 #<!-- -->8 0x000000000437775b Fortran::semantics::CheckHelper::CheckProcBinding(Fortran::semantics::Symbol const&amp;, Fortran::semantics::ProcBindingDetails const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x437775b)
 #<!-- -->9 0x0000000004388705 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Symbol const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4388705)
#<!-- -->10 0x000000000438893c Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x438893c)
#<!-- -->11 0x00000000043889a8 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x43889a8)
#<!-- -->12 0x00000000043889a8 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x43889a8)
#<!-- -->13 0x0000000004388fed Fortran::semantics::CheckDeclarations(Fortran::semantics::SemanticsContext&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4388fed)
#<!-- -->14 0x000000000426be77 Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x426be77)
#<!-- -->15 0x00000000038c2005 Fortran::frontend::FrontendAction::runSemanticChecks() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c2005)
#<!-- -->16 0x0000000003bef85a Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x3bef85a)
#<!-- -->17 0x00000000038c1415 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&amp;, Fortran::frontend::FrontendInputFile const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c1415)
#<!-- -->18 0x00000000038b0d17 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38b0d17)
#<!-- -->19 0x00000000038c745d Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x38c745d)
#<!-- -->20 0x0000000002020c08 fc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x2020c08)
#<!-- -->21 0x0000000001f0ede4 main (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x1f0ede4)
#<!-- -->22 0x00007c8aaec29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->23 0x00007c8aaec29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->24 0x000000000201fb6e _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x201fb6e)
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 881f20e958e80bd30463fc57d2d3e891bcb8a571)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin

klausler added a commit to klausler/llvm-project that referenced this issue May 20, 2024
A type-bound procedure that's bound to a name that isn't a
procedure is caught as an error, but can also lead to a crash
in compatibility checking later.  Make that code more robust
to failure.

Fixes llvm#92678.
@klausler
Copy link
Contributor

#92800

@klausler klausler self-assigned this May 20, 2024
klausler added a commit that referenced this issue May 23, 2024
A type-bound procedure that's bound to a name that isn't a procedure is
caught as an error, but can also lead to a crash in compatibility
checking later. Make that code more robust to failure.

Fixes #92678.
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:frontend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants