llvm / llvm/llvm-project

[flang] crash at flang/include/flang/Semantics/symbol.h

Open
#210,047 5 comments 0 reactions 0 assignees View on GitHub
crash flang:frontend generated by fuzzer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://godbolt.org/z/xnrEWx6T3

The following code:

```fortran
subroutine test3()
common /blk/ k1
equivalence(i1,TEST3,k1)
end subroutine test3
```

Resulted in this output:
```
fatal internal error: CHECK(p) failed at flang/include/flang/Semantics/symbol.h(902)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /usr/lib/llvm-22/bin/flang -fc1 -triple x86_64-pc-linux-gnu -emit-obj -ffree-form -fdefault-integer-8 -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -vectorize-loops -vectorize-slp -fversion-loops-for-stride -finit-global-zero -std=f2018 -resource-dir /usr/lib/llvm-22/lib/clang/22 -mframe-pointer=none -O3 -o /tmp/test-7c139a.o -x f95 /tmp/test.f90
#0 0x00007f147fda1d5f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-22/lib/libLLVM.so.22.1+0x4dc7d5f)
#1 0x00007f147fd9f5d7 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-22/lib/libLLVM.so.22.1+0x4dc55d7)
#2 0x00007f147fda2b2a (/usr/lib/llvm-22/lib/libLLVM.so.22.1+0x4dc8b2a)
#3 0x00007f147aa76330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x00007f147aacfb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#5 0x00007f147aa7627e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#6 0x00007f147aa598ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#7 0x0000564af37f661c (/usr/lib/llvm-22/bin/flang+0x2b2061c)
#8 0x0000564af2277e8e Fortran::semantics::ComputeOffsetsHelper::Compute(Fortran::semantics::Scope&) (/usr/lib/llvm-22/bin/flang+0x15a1e8e)
#9 0x0000564af22777a2 Fortran::semantics::ComputeOffsetsHelper::Compute(Fortran::semantics::Scope&) (/usr/lib/llvm-22/bin/flang+0x15a17a2)
#10 0x0000564af2277f1f Fortran::semantics::ComputeOffsets(Fortran::semantics::SemanticsContext&, Fortran::semantics::Scope&) (/usr/lib/llvm-22/bin/flang+0x15a1f1f)
#11 0x0000564af215102c Fortran::semantics::Semantics::Perform() (/usr/lib/llvm-22/bin/flang+0x147b02c)
#12 0x0000564af18a091e Fortran::frontend::FrontendAction::runSemanticChecks() (/usr/lib/llvm-22/bin/flang+0xbca91e)
#13 0x0000564af18a57da Fortran::frontend::CodeGenAction::beginSourceFileAction() (/usr/lib/llvm-22/bin/flang+0xbcf7da)
#14 0x0000564af189ff9e Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/usr/lib/llvm-22/bin/flang+0xbc9f9e)
#15 0x0000564af1887e7f Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/usr/lib/llvm-22/bin/flang+0xbb1e7f)
#16 0x0000564af18a4ba0 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/usr/lib/llvm-22/bin/flang+0xbceba0)
#17 0x0000564af1885d34 fc1_main(llvm::ArrayRef, char const*) (/usr/lib/llvm-22/bin/flang+0xbafd34)
#18 0x0000564af1884fa4 main (/usr/lib/llvm-22/bin/flang+0xbaefa4)
#19 0x00007f147aa5b1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#20 0x00007f147aa5b28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#21 0x0000564af1883f45 _start (/usr/lib/llvm-22/bin/flang+0xbadf45)
flang-22: error: unable to execute command: Aborted (core dumped)
flang-22: error: flang frontend command failed due to signal (use -v to see invocation)
Ubuntu flang version 22.1.8 (++20260613092238+e80beda6e255-1~exp1~20260613092253.78)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-22/bin
flang-22: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-22: note: diagnostic msg: /tmp/test-6d4f73
flang-22: note: diagnostic msg: /tmp/test-6d4f73.sh
flang-22: note: diagnostic msg:

********************
```

To reproduce:
```
flang ./test.f90
```

Compiler version:
```
Ubuntu flang version 22.1.8 (++20260613092238+e80beda6e255-1~exp1~20260613092253.78)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-22/bin
```

*This bug was found by [fusion-fuzz](https://github.com/fusion-fuzz/fusion-fuzz)*

Contributor guide

Open the contributing guide

Research direction

Start with the reproducer in the issue and inspect flang/include/flang/Semantics/symbol.h around line 902, then follow the ComputeOffsetsHelper::Compute stack frames shown in the report. Run `flang ./test.f90` with the supplied Fortran source to confirm the failure. Done means the reproducer no longer aborts with the CHECK failure and receives the appropriate compiler behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.