llvm / llvm/llvm-project

[flang] crash: "No error was reported but setting error on subprogram" when shadowing int_ptr_kind under -fimplicit-none

Open
#209,074 1 comment 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/KcfqKPdr5

The following code:

```fortran
subroutine s(INT_PTR_KIND,n)
integer(int_ptr_kind()) n
end subroutine
```

Resulted in this output:
```

fatal internal error: No error was reported but setting error on: s (Subroutine): Subprogram (int_ptr_kind,INTEGER(8) n)
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-llvm -ffree-form -fimplicit-none -falternative-parameter-statement -fdefault-real-8 -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -resource-dir /usr/lib/llvm-22/lib/clang/22 -mframe-pointer=none -O1 -o /dev/null -x f95 /tmp/test.f90
#0 0x00007f90df470d5f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-22/lib/libLLVM.so.22.1+0x4dc7d5f)
#1 0x00007f90df46e5d7 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-22/lib/libLLVM.so.22.1+0x4dc55d7)
#2 0x00007f90df471b2a (/usr/lib/llvm-22/lib/libLLVM.so.22.1+0x4dc8b2a)
#3 0x00007f90da145330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x00007f90da19eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#5 0x00007f90da14527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#6 0x00007f90da1288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#7 0x000055f9628b061c (/usr/lib/llvm-22/bin/flang+0x2b2061c)
#8 0x000055f96120938a (/usr/lib/llvm-22/bin/flang+0x147938a)
#9 0x000055f96133eb1f Fortran::semantics::CheckHelper::CheckSubprogram(Fortran::semantics::Symbol const&, Fortran::semantics::SubprogramDetails const&) (/usr/lib/llvm-22/bin/flang+0x15aeb1f)
#10 0x000055f961333fb7 Fortran::semantics::CheckHelper::Check(Fortran::semantics::Symbol const&) (/usr/lib/llvm-22/bin/flang+0x15a3fb7)
#11 0x000055f96134496c Fortran::semantics::CheckHelper::Check(Fortran::semantics::Scope const&) (/usr/lib/llvm-22/bin/flang+0x15b496c)
#12 0x000055f96134ada9 Fortran::semantics::CheckDeclarations(Fortran::semantics::SemanticsContext&) (/usr/lib/llvm-22/bin/flang+0x15bada9)
#13 0x000055f96120b034 Fortran::semantics::Semantics::Perform() (/usr/lib/llvm-22/bin/flang+0x147b034)
#14 0x000055f96095a91e Fortran::frontend::FrontendAction::runSemanticChecks() (/usr/lib/llvm-22/bin/flang+0xbca91e)
#15 0x000055f96095f7da Fortran::frontend::CodeGenAction::beginSourceFileAction() (/usr/lib/llvm-22/bin/flang+0xbcf7da)
#16 0x000055f960959f9e Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/usr/lib/llvm-22/bin/flang+0xbc9f9e)
#17 0x000055f960941e7f Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/usr/lib/llvm-22/bin/flang+0xbb1e7f)
#18 0x000055f96095eba0 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/usr/lib/llvm-22/bin/flang+0xbceba0)
#19 0x000055f96093fd34 fc1_main(llvm::ArrayRef, char const*) (/usr/lib/llvm-22/bin/flang+0xbafd34)
#20 0x000055f96093efa4 main (/usr/lib/llvm-22/bin/flang+0xbaefa4)
#21 0x00007f90da12a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#22 0x00007f90da12a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#23 0x000055f96093df45 _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-aea315
flang-22: note: diagnostic msg: /tmp/test-aea315.sh
flang-22: note: diagnostic msg:

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

To reproduce:
```
flang -fimplicit-none ./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 by reproducing the crash with flang -fimplicit-none on the test.f90 example or the linked Godbolt case, then trace the semantic-checking path indicated by CheckSubprogram in the stack trace. Done means the reproducer no longer aborts with the fatal internal error; add regression coverage if the project’s existing Flang tests provide a suitable location.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.