https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66310

--- Comment #14 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
On x86_64-apple-darwin15 with 16Gb of RAM and ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 65532
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited

with the patch at https://gcc.gnu.org/ml/fortran/2016-07/msg00097.html
compiling the test

   program p
      character(len=2,kind=4), parameter :: z = 'yz'
      print *, repeat(z, 2**25)
   end

fails at compile time with

f951(36102,0x7fff74e38000) malloc: *** mach_vm_map(size=18446744073441116160)
failed (error code=3)

Compiling the following tests with -m64 (z is no longer a parameter)

   program p
      character :: z = 'z'
      print *, repeat(z, huge(1)-2**9)
   end

gives

a.out(92056,0x7fff74e38000) malloc: *** mach_vm_map(size=18446744071562067968)
failed (error code=3)
*** error: can't allocate region

   program p
      character(len=2,kind=4) :: z = 'yz'
      print *, repeat(z, huge(1)/8+2)
   end

and

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

The codes execute without any problem if the repeat counts are decremented by
one (tested 1024 times for the first case).

Compiling the following code with -m32

   program p
      character :: z = 'z'
      print *, repeat(z, 2**30-2**21+2**12-1)
   end

gave an executable failing 7 times over 2048 runs with

...
real    0m5.318s
user    0m1.058s
sys     0m1.860s
a.out(49086,0xa37d2000) malloc: *** mach_vm_map(size=1071652864) failed (error
code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Operating system error: Cannot allocate memory
Memory allocation failure in xrealloc

Error termination. Backtrace:
#0  0x758f
#1  0x824d
#2  0x845f
#3  0x6dbb
#4  0xbd1a4
#5  0xafcfc
#6  0xb7832
#7  0xbcda5
#8  0xafb26
#9  0x2dff
#10  0x2e5f

real    0m1.197s
user    0m0.787s
sys     0m0.373s
...

while decrementing the repeat count by one runs 2048 times without failure.
Also

   program p
      character :: z = 'z'
      print *, repeat(z, 2**30-2**20)
   end

fails at run time with

a.out(35477,0xa37d2000) malloc: *** mach_vm_map(size=1072697344) failed (error
code=3)

Reply via email to