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

--- Comment #48 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
(In reply to Jerry DeLisle from comment #47)
> I have a proposed fix I am posting on the lists for review.

Hi Jerry!

The patch posted in https://gcc.gnu.org/pipermail/fortran/2026-June/064021.html
works for your new testcase, but it still fails for me on the original one:

% gfc-17 assumed_rank_7.f90 -fsanitize=address -g -O && ./a.out 
=================================================================
==229914==ERROR: AddressSanitizer: stack-buffer-overflow on address
0x7bc6b00f0098 at pc 0x7fc6b272700c bp 0x7fff508c3f50 sp 0x7fff508c3710
READ of size 360 at 0x7bc6b00f0098 thread T0
    #0 0x7fc6b272700b in memcpy
../../../../gcc-trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:117
    #1 0x000000401dfe in MAIN__ /home/anlauf/gcc-bugs/assumed_rank_7.f90:25
    #2 0x0000004029fe in main /home/anlauf/gcc-bugs/assumed_rank_7.f90:29
    #3 0x7fc6b1f4933f in __libc_start_call_main (/lib64/libc.so.6+0x2a33f)
(BuildId: 006575e9bb6ed7fbad2200bd738302755ce502d4)
    #4 0x7fc6b1f49408 in __libc_start_main_alias_1 (/lib64/libc.so.6+0x2a408)
(BuildId: 006575e9bb6ed7fbad2200bd738302755ce502d4)
    #5 0x0000004011e4 in _start ../sysdeps/x86_64/start.S:115

Address 0x7bc6b00f0098 is located in stack of thread T0 at offset 152 in frame
    #0 0x000000401a6e in MAIN__ /home/anlauf/gcc-bugs/assumed_rank_7.f90:11

  This frame has 8 object(s):
    [32, 48) 'FRAME.30' (line 11)
    [64, 152) 'at' (line 17)
    [192, 280) 'atmp.22' (line 26) <== Memory access at offset 152 partially
underflows this variable
    [320, 408) 'parm.27' (line 27) <== Memory access at offset 152 partially
underflows this variable
    [448, 856) 'class.19' (line 24) <== Memory access at offset 152 partially
underflows this variable
    [928, 1336) 'class.20' (line 25)
    [1408, 1816) 'class.13' (line 39)
    [1888, 2296) 'class.13' (line 39)
HINT: this may be a false positive if your program uses some custom stack
unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow
/home/anlauf/gcc-bugs/assumed_rank_7.f90:25 in MAIN__
Shadow bytes around the buggy address:
  0x7bc6b00efe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc6b00efe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc6b00eff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc6b00eff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc6b00f0000: f1 f1 f1 f1 00 00 f2 f2 00 00 00 00 00 00 00 00
=>0x7bc6b00f0080: 00 00 00[f2]f2 f2 f2 f2 00 00 00 00 00 00 00 00
  0x7bc6b00f0100: 00 00 00 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00
  0x7bc6b00f0180: 00 00 00 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00
  0x7bc6b00f0200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc6b00f0280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7bc6b00f0300: 00 00 00 00 00 00 00 00 00 00 00 f2 f2 f2 f2 f2
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==229914==ABORTING

Reply via email to