Issue 139776
Summary [flang][openacc] Flang hangs and continuously allocates memory when compiling gfortran test: goacc/loop-3.f95
Labels flang
Assignees
Reporter tarunprabhu
    Steps to reproduce:

Assuming that the [LLVM test suite](https://github.com/llvm/llvm-test-suite) is checked out in `./llvm-test-suite`, compile the test as follows:

```
$ flang -fopenacc ./llvm-test-suite/Fortran/gfortran/regression/goacc/loop-3.f95
```

Observed behavior: Some warning messages are printed following which flang hangs and continuously allocates memory until either manually killed or an OOM error occurs. This was run with `/usr/bin/time -v` and terminated with `SIGTERM` after approx. 1 minute. The output in this case is provided below. Note the maximum resident set size and the number of page faults. 

```
./llvm-test-suite/Fortran/gfortran/regression/goacc/loop-3.f95:18:9: warning: Misplaced OpenACC end directive
    !$acc end loop ! { dg-error "Unexpected" }
 ^^^^^^^^
./llvm-test-suite/Fortran/gfortran/regression/goacc/loop-3.f95:25:9: warning: Misplaced OpenACC end directive
    !$acc end loop ! { dg-error "Unexpected" }
 ^^^^^^^^
./llvm-test-suite/Fortran/gfortran/regression/goacc/loop-3.f95:32:9: warning: Misplaced OpenACC end directive
    !$acc end loop ! { dg-error "Unexpected" }
          ^^^^^^^^
flang-21: error: unable to execute command: Terminated
flang-21: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 21.0.0git (g...@github.com:llvm-project-tlp/llvm-project.git 84c1564d1825880d463d9f85153812f1f6805289)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/bin
Build config: +assertions
flang-21: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-21: note: diagnostic msg: /tmp/loop-3-2b0785
flang-21: note: diagnostic msg: /tmp/loop-3-2b0785.sh
flang-21: note: diagnostic msg: 

********************
Command exited with non-zero status 254
	Command being timed: "/path/to/bin/flang -fopenacc ./llvm-test-suite/Fortran/gfortran/regression/goacc/loop-3.f95"
	User time (seconds): 18.04
	System time (seconds): 53.96
	Percent of CPU this job got: 99%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 1:12.41
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 93215748
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 3
	Minor (reclaiming a frame) page faults: 23283575
	Voluntary context switches: 178
	Involuntary context switches: 96
	Swaps: 0
	File system inputs: 0
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 254

```

What follows is a minimal section of code from the original test that seems to reproduce this behavior.

```fortran
subroutine test1
  implicit none
  integer :: i, j

  outer_loop1: do i = 1, 5
    !$acc loop
    inner_loop1: do j = 1,5
      if (i .eq. j) cycle outer_loop1 ! { dg-error "CYCLE statement" }
    end do inner_loop1
  end do outer_loop1
end subroutine test1
```

Another gfortran test, `goacc/loop-3-2.f95` also exhibits similar behavior.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to