This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/69930] New: fortran address sanitizer does not work with optimization


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

            Bug ID: 69930
           Summary: fortran address sanitizer does not work with
                    optimization
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: physiker at toast2 dot net
  Target Milestone: ---

Created attachment 37776
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37776&action=edit
Source code

When the code bnd11.f90, included in polyhedrons linux fortran testsuite, is
compiled without optimization the address sanitizer catches the error. With
optimization turned on, the address sanitizer does not spot the error. The
execution of the program is not stopped by the sanitizer.
bash-3.2$ gfortran -v -W -Wall bnd11.f90 -fsanitize=address -o bnd11
Driving: gfortran -mmacosx-version-min=10.9.4 -v -W -Wall bnd11.f90
-fsanitize=address -o bnd11 -l gfortran -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/lto-wrapper
Target: x86_64-apple-darwin13.4.0
Configured with: ../gcc-5.3.0/configure --prefix=/sw --prefix=/sw/lib/gcc5
--mandir=/sw/share/man --infodir=/sw/lib/gcc5/info
--enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw
--with-libiconv-prefix=/sw --with-isl=/sw --with-mpc=/sw --with-system-zlib
--program-suffix=-fsf-5
Thread model: posix
gcc version 5.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.4' '-v' '-Wextra' '-Wall'
'-fsanitize=address' '-o' 'bnd11' '-shared-libgcc' '-mtune=core2'
 /sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/f951 bnd11.f90 -fPIC
-quiet -dumpbase bnd11.f90 -mmacosx-version-min=10.9.4 -mtune=core2 -auxbase
bnd11 -Wextra -Wall -version -fsanitize=address -fintrinsic-modules-path
/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/finclude -o
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//ccqRKgpk.s
GNU Fortran (GCC) version 5.3.0 (x86_64-apple-darwin13.4.0)
        compiled by GNU C version 5.3.0, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
warning: GMP header version 6.0.0 differs from library version 6.1.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 5.3.0 (x86_64-apple-darwin13.4.0)
        compiled by GNU C version 5.3.0, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
warning: GMP header version 6.0.0 differs from library version 6.1.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.4' '-v' '-Wextra' '-Wall'
'-fsanitize=address' '-o' 'bnd11' '-shared-libgcc' '-mtune=core2'
 as -arch x86_64 -force_cpusubtype_ALL -o
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//ccmU9RIS.o
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//ccqRKgpk.s
Reading specs from
/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.4' '-v' '-Wextra' '-Wall'
'-fsanitize=address' '-o' 'bnd11' '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/:/sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/:/sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/:/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/:/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/
LIBRARY_PATH=/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/:/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.4' '-v' '-Wextra' '-Wall'
'-fsanitize=address' '-o' 'bnd11' '-shared-libgcc' '-mtune=core2'
 /sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/collect2 -dynamic
-arch x86_64 -macosx_version_min 10.9.4 -weak_reference_mismatches non-weak -o
bnd11 -L/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0
-L/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/../../..
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//ccmU9RIS.o -lgfortran -lasan
-no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5
-lgcc -lSystem -v
collect2 version 5.3.0
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.9.4
-weak_reference_mismatches non-weak -o bnd11
-L/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0
-L/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/../../..
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//ccmU9RIS.o -lgfortran -lasan
-no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5
-lgcc -lSystem -v
@(#)PROGRAM:ld  PROJECT:ld64-241.9
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h
armv6m armv7m armv7em
Library search paths:
        /sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0
        /sw/lib/gcc5/lib
        /usr/lib
        /usr/local/lib
Framework search paths:
        /Library/Frameworks/
        /System/Library/Frameworks/
 /usr/bin/nm -n /var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//ccmU9RIS.o
bash-3.2$ ./bnd11
=================================================================
==533==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60400000dc78
at pc 0x000105bc8c2d bp 0x7fff5a0381a0 sp 0x7fff5a038198
WRITE of size 4 at 0x60400000dc78 thread T0
    #0 0x105bc8c2c  (/Users/Peter/Downloads/linux_diagnose/./bnd11+0x100001c2c)
    #1 0x105bc8c77  (/Users/Peter/Downloads/linux_diagnose/./bnd11+0x100001c77)
    #2 0x7fff8aca95fc  (/usr/lib/system/libdyld.dylib+0x35fc)
    #3 0x0  (<unknown module>)

0x60400000dc78 is located 0 bytes to the right of 40-byte region
[0x60400000dc50,0x60400000dc78)
allocated by thread T0 here:
    #0 0x105c020da  (/sw/lib/gcc5/lib/libasan.2.dylib+0x320da)
    #1 0x105bc87ff  (/Users/Peter/Downloads/linux_diagnose/./bnd11+0x1000017ff)
    #2 0x105bc8c77  (/Users/Peter/Downloads/linux_diagnose/./bnd11+0x100001c77)
    #3 0x7fff8aca95fc  (/usr/lib/system/libdyld.dylib+0x35fc)
    #4 0x0  (<unknown module>)

SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 ??
Shadow bytes around the buggy address:
  0x1c0800001b30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0800001b40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0800001b50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0800001b60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0800001b70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x1c0800001b80: fa fa fa fa fa fa fa fa fa fa 00 00 00 00 00[fa]
  0x1c0800001b90: fa fa 00 00 00 00 00 00 fa fa 00 00 00 00 00 06
  0x1c0800001ba0: fa fa 00 00 00 00 00 05 fa fa 00 00 00 00 00 07
  0x1c0800001bb0: fa fa 00 00 00 00 00 05 fa fa 00 00 00 00 00 05
  0x1c0800001bc0: fa fa fd fd fd fd fd fa fa fa fd fd fd fd fd fd
  0x1c0800001bd0: fa fa fd fd fd fd fd fa fa fa 00 00 00 00 01 fa
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
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  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
==533==ABORTING
bash-3.2$ gfortran -v -O -W -Wall bnd11.f90 -fsanitize=address -o bnd11
Driving: gfortran -mmacosx-version-min=10.9.4 -v -O -W -Wall bnd11.f90
-fsanitize=address -o bnd11 -l gfortran -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/lto-wrapper
Target: x86_64-apple-darwin13.4.0
Configured with: ../gcc-5.3.0/configure --prefix=/sw --prefix=/sw/lib/gcc5
--mandir=/sw/share/man --infodir=/sw/lib/gcc5/info
--enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw
--with-libiconv-prefix=/sw --with-isl=/sw --with-mpc=/sw --with-system-zlib
--program-suffix=-fsf-5
Thread model: posix
gcc version 5.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.4' '-v' '-O' '-Wextra' '-Wall'
'-fsanitize=address' '-o' 'bnd11' '-shared-libgcc' '-mtune=core2'
 /sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/f951 bnd11.f90 -fPIC
-quiet -dumpbase bnd11.f90 -mmacosx-version-min=10.9.4 -mtune=core2 -auxbase
bnd11 -O -Wextra -Wall -version -fsanitize=address -fintrinsic-modules-path
/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/finclude -o
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//ccPhzE6T.s
GNU Fortran (GCC) version 5.3.0 (x86_64-apple-darwin13.4.0)
        compiled by GNU C version 5.3.0, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
warning: GMP header version 6.0.0 differs from library version 6.1.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 5.3.0 (x86_64-apple-darwin13.4.0)
        compiled by GNU C version 5.3.0, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
warning: GMP header version 6.0.0 differs from library version 6.1.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.4' '-v' '-O' '-Wextra' '-Wall'
'-fsanitize=address' '-o' 'bnd11' '-shared-libgcc' '-mtune=core2'
 as -arch x86_64 -force_cpusubtype_ALL -o
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//cccxtYUI.o
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//ccPhzE6T.s
Reading specs from
/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.4' '-v' '-O' '-Wextra' '-Wall'
'-fsanitize=address' '-o' 'bnd11' '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/:/sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/:/sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/:/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/:/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/
LIBRARY_PATH=/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/:/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.4' '-v' '-O' '-Wextra' '-Wall'
'-fsanitize=address' '-o' 'bnd11' '-shared-libgcc' '-mtune=core2'
 /sw/lib/gcc5/libexec/gcc/x86_64-apple-darwin13.4.0/5.3.0/collect2 -dynamic
-arch x86_64 -macosx_version_min 10.9.4 -weak_reference_mismatches non-weak -o
bnd11 -L/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0
-L/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/../../..
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//cccxtYUI.o -lgfortran -lasan
-no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5
-lgcc -lSystem -v
collect2 version 5.3.0
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.9.4
-weak_reference_mismatches non-weak -o bnd11
-L/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0
-L/sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0/../../..
/var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//cccxtYUI.o -lgfortran -lasan
-no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5
-lgcc -lSystem -v
@(#)PROGRAM:ld  PROJECT:ld64-241.9
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h
armv6m armv7m armv7em
Library search paths:
        /sw/lib/gcc5/lib/gcc/x86_64-apple-darwin13.4.0/5.3.0
        /sw/lib/gcc5/lib
        /usr/lib
        /usr/local/lib
Framework search paths:
        /Library/Frameworks/
        /System/Library/Frameworks/
 /usr/bin/nm -n /var/folders/97/4qnhjhtn25s86s9hkz0h37_m0000gn/T//cccxtYUI.o
bash-3.2$ ./bnd11
Does not stop

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]