flang-compiler / f18-llvm-project

Fork of llvm/llvm-project for f18. In sync with f18-mlir and f18.
http://llvm.org
28 stars 16 forks source link

Small repro for SPEC 2000 178.galgel seg fault at runtime #988

Open sscalpone opened 3 years ago

sscalpone commented 3 years ago
module a
  parameter (nx=50, ny=20, n=nx*ny)
  real*8, dimension(n,n) :: h
end module

subroutine div(p)
  use a
  real p
  h(1:n,1:n) = h(1:n,1:n) / p
end

  use a
  h(1:n,1:n) = 4.0
  call div(2.0)
end
% flang foo.f90
% a.out
Segmentation fault
% gdb a.out
(gdb) run
Starting program: a.out
Program received signal SIGSEGV, Segmentation fault.
0x00000000004016ba in _QPdiv () at foo.f90:9
9         h(1:n,1:n) = h(1:n,1:n) / p
(gdb)
sscalpone commented 3 years ago

Smaller.

  parameter (nx=50, ny=20, n=nx*ny)
  real*8, dimension(n,n) :: h
  real p
  p = 2.0
  h(1:n,1:n) = 4.0
  h(1:n,1:n) = h(1:n,1:n) / p
end

Or

  real*8, dimension(1000,1000) :: h
  h(1:1000,1:1000) = 4.0
  h(1:1000,1:1000) = h(1:1000,1:1000) / 2.0
end
svedan commented 3 years ago

Eric thinks this has to do with array expressions.

sscalpone commented 3 years ago

Ping.

schweitzpgi commented 3 years ago

Looks like it is trying to allocate a buffer 1,000,000 times too large. Lowering bug.

svedan commented 3 years ago

Assigning this to Val.

vdonaldson commented 2 years ago

After a sequence of fixes, these three tests compile and execute to completion. Similar tests that verify result elements are also ok. A variation of the problem remains with:

  subroutine ss4(n)
    real aa(1050,n)
    aa = aa + 7.0
  end