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] flang-new crashes when equivalence attribute conflicts with allocatable attribute #92636

Closed
k-arrows opened this issue May 18, 2024 · 4 comments · Fixed by #92786
Closed
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/Tqr6eb3dz

Reproducer:

$ cat test.f90
allocatable :: i(:), j(:)
equivalence(i, j)
end

Stack dump:

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 0x00007575cce42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007575cce969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007575cce42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007575cce287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000001edd217 (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x1edd217)
 #7 0x00000000041daf3d Fortran::semantics::DeclarationVisitor::CheckEquivalenceSets() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41daf3d)
 #8 0x00000000041decbf Fortran::semantics::ResolveNamesVisitor::FinishSpecificationPart(std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>> const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41decbf)
 #9 0x00000000041eb9f8 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::SpecificationPart const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41eb9f8)
#10 0x00000000041e9a89 std::enable_if<TupleTrait<Fortran::parser::SpecificationPart>, void>::type Fortran::parser::Walk<Fortran::parser::SpecificationPart, Fortran::semantics::ResolveNamesVisitor>(Fortran::parser::SpecificationPart const&, Fortran::semantics::ResolveNamesVisitor&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41e9a89)
#11 0x0000000004210e64 Fortran::semantics::ResolveNamesVisitor::ResolveSpecificationParts(Fortran::semantics::ProgramTree&) (.part.0) resolve-names.cpp:0:0
#12 0x00000000042114f6 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x42114f6)
#13 0x0000000004212a04 Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&, Fortran::semantics::Scope&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4212a04)
#14 0x000000000426be51 Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x426be51)
#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 0x00007575cce29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#23 0x00007575cce29e40 __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 18, 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 18, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 18, 2024

@llvm/issue-subscribers-flang-frontend

Author: None (k-arrows)

Reproducible on Godbolt: https://godbolt.org/z/Tqr6eb3dz

Reproducer:

$ cat test.f90
allocatable :: i(:), j(:)
equivalence(i, j)
end

Stack dump:

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 0x00007575cce42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->3 0x00007575cce969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->4 0x00007575cce42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->5 0x00007575cce287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->6 0x0000000001edd217 (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x1edd217)
 #<!-- -->7 0x00000000041daf3d Fortran::semantics::DeclarationVisitor::CheckEquivalenceSets() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41daf3d)
 #<!-- -->8 0x00000000041decbf Fortran::semantics::ResolveNamesVisitor::FinishSpecificationPart(std::__cxx11::list&lt;Fortran::parser::DeclarationConstruct, std::allocator&lt;Fortran::parser::DeclarationConstruct&gt;&gt; const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41decbf)
 #<!-- -->9 0x00000000041eb9f8 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::SpecificationPart const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41eb9f8)
#<!-- -->10 0x00000000041e9a89 std::enable_if&lt;TupleTrait&lt;Fortran::parser::SpecificationPart&gt;, void&gt;::type Fortran::parser::Walk&lt;Fortran::parser::SpecificationPart, Fortran::semantics::ResolveNamesVisitor&gt;(Fortran::parser::SpecificationPart const&amp;, Fortran::semantics::ResolveNamesVisitor&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41e9a89)
#<!-- -->11 0x0000000004210e64 Fortran::semantics::ResolveNamesVisitor::ResolveSpecificationParts(Fortran::semantics::ProgramTree&amp;) (.part.0) resolve-names.cpp:0:0
#<!-- -->12 0x00000000042114f6 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x42114f6)
#<!-- -->13 0x0000000004212a04 Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&amp;, Fortran::parser::Program const&amp;, Fortran::semantics::Scope&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4212a04)
#<!-- -->14 0x000000000426be51 Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x426be51)
#<!-- -->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 0x00007575cce29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->23 0x00007575cce29e40 __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/Tqr6eb3dz

Reproducer:

$ cat test.f90
allocatable :: i(:), j(:)
equivalence(i, j)
end

Stack dump:

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 0x00007575cce42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->3 0x00007575cce969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->4 0x00007575cce42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->5 0x00007575cce287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->6 0x0000000001edd217 (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x1edd217)
 #<!-- -->7 0x00000000041daf3d Fortran::semantics::DeclarationVisitor::CheckEquivalenceSets() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41daf3d)
 #<!-- -->8 0x00000000041decbf Fortran::semantics::ResolveNamesVisitor::FinishSpecificationPart(std::__cxx11::list&lt;Fortran::parser::DeclarationConstruct, std::allocator&lt;Fortran::parser::DeclarationConstruct&gt;&gt; const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41decbf)
 #<!-- -->9 0x00000000041eb9f8 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::SpecificationPart const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41eb9f8)
#<!-- -->10 0x00000000041e9a89 std::enable_if&lt;TupleTrait&lt;Fortran::parser::SpecificationPart&gt;, void&gt;::type Fortran::parser::Walk&lt;Fortran::parser::SpecificationPart, Fortran::semantics::ResolveNamesVisitor&gt;(Fortran::parser::SpecificationPart const&amp;, Fortran::semantics::ResolveNamesVisitor&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x41e9a89)
#<!-- -->11 0x0000000004210e64 Fortran::semantics::ResolveNamesVisitor::ResolveSpecificationParts(Fortran::semantics::ProgramTree&amp;) (.part.0) resolve-names.cpp:0:0
#<!-- -->12 0x00000000042114f6 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x42114f6)
#<!-- -->13 0x0000000004212a04 Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&amp;, Fortran::parser::Program const&amp;, Fortran::semantics::Scope&amp;) (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x4212a04)
#<!-- -->14 0x000000000426be51 Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20240518/bin/flang-new+0x426be51)
#<!-- -->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 0x00007575cce29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->23 0x00007575cce29e40 __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 klausler self-assigned this May 20, 2024
@klausler
Copy link
Contributor

If possible, please omit the $ cat foo.f90 line from your test cases.

klausler added a commit to klausler/llvm-project that referenced this issue May 20, 2024
EQUIVALENCE set processing assumes that any arrays have explicit
shape and constant lower bounds.  When an erroneous program
violates those assumptions, the compiler crashes.  Fix.

Fixes llvm#92636.
@klausler
Copy link
Contributor

#92786

klausler added a commit that referenced this issue May 23, 2024
EQUIVALENCE set processing assumes that any arrays have explicit shape
and constant lower bounds. When an erroneous program violates those
assumptions, the compiler crashes. Fix.

Fixes #92636.
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