gcc - Large common blocks with address sanitizer in 32-bit mode -


i'm having problem legacy fortran code can reduced sample:

program main implicit none write(6,*) 'hello!' end program main  subroutine bigdata() implicit none !real*8 aa(50292712) real*8 aa(50292713) common /big_common/ aa end subroutine 

note subroutine never called program. compiling , running in 64-bit machine, gives me:

$ gfortran -fsanitize=address main.f ; ./a.out  hello!  $ gfortran -m32 main.f ; ./a.out  hello!  $ gfortran -m32 -fsanitize=address main.f ; ./a.out                                                                                                                ==32656== shadow memory range interleaves existing memory mapping. asan cannot proceed correctly. aborting. ==32656== process memory map follows:         0x08048000-0x08049000   /home/username/a.out         0x08049000-0x0804a000   /home/username/a.out         0x0804a000-0x0804b000   /home/username/a.out         0x0804b000-0x1ffff000         0xf5d77000-0xf5d78000         0xf5d78000-0xf5dbc000   /lib/i386-linux-gnu/libm-2.19.so         0xf5dbc000-0xf5dbd000   /lib/i386-linux-gnu/libm-2.19.so         0xf5dbd000-0xf5dbe000   /lib/i386-linux-gnu/libm-2.19.so         0xf5dbe000-0xf5dbf000         0xf5dbf000-0xf5e38000   /usr/lib32/libquadmath.so.0.0.0         0xf5e38000-0xf5e39000   /usr/lib32/libquadmath.so.0.0.0         0xf5e39000-0xf5e3a000   /usr/lib32/libquadmath.so.0.0.0         0xf5e3a000-0xf5e56000   /lib/i386-linux-gnu/libgcc_s.so.1         0xf5e56000-0xf5e57000   /lib/i386-linux-gnu/libgcc_s.so.1         0xf5e57000-0xf5e5a000   /lib/i386-linux-gnu/libdl-2.19.so         0xf5e5a000-0xf5e5b000   /lib/i386-linux-gnu/libdl-2.19.so         0xf5e5b000-0xf5e5c000   /lib/i386-linux-gnu/libdl-2.19.so         0xf5e5c000-0xf5e74000   /lib/i386-linux-gnu/libpthread-2.19.so         0xf5e74000-0xf5e75000   /lib/i386-linux-gnu/libpthread-2.19.so         0xf5e75000-0xf5e76000   /lib/i386-linux-gnu/libpthread-2.19.so         0xf5e76000-0xf5e78000         0xf5e78000-0xf6020000   /lib/i386-linux-gnu/libc-2.19.so         0xf6020000-0xf6022000   /lib/i386-linux-gnu/libc-2.19.so         0xf6022000-0xf6023000   /lib/i386-linux-gnu/libc-2.19.so         0xf6023000-0xf6027000         0xf6027000-0xf6123000   /usr/lib32/libgfortran.so.3.0.0         0xf6123000-0xf6124000   /usr/lib32/libgfortran.so.3.0.0         0xf6124000-0xf6125000   /usr/lib32/libgfortran.so.3.0.0         0xf6125000-0xf6151000   /usr/lib32/libasan.so.0.0.0         0xf6151000-0xf6152000   /usr/lib32/libasan.so.0.0.0         0xf6152000-0xf6153000   /usr/lib32/libasan.so.0.0.0         0xf6153000-0xf7705000         0xf7731000-0xf773b000         0xf773b000-0xf773c000   [vdso]         0xf773c000-0xf775c000   /lib/i386-linux-gnu/ld-2.19.so         0xf775c000-0xf775d000   /lib/i386-linux-gnu/ld-2.19.so         0xf775d000-0xf775e000   /lib/i386-linux-gnu/ld-2.19.so         0xff80a000-0xff82c000   [stack] ==32656== end of process memory map. 

gfortran version:

$ gfortran -v using built-in specs. collect_gcc=gfortran collect_lto_wrapper=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper target: x86_64-linux-gnu configured with: ../src/configure -v --with-pkgversion='ubuntu 4.8.4-2ubuntu1~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.8/readme.bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu thread model: posix gcc version 4.8.4 (ubuntu 4.8.4-2ubuntu1~14.04.1) 

reducing size of aa 1 (in test) gets rid of problem. limiting size may different in different systems or situations.

as far can see, size of common block near 2gb, i'd expect -m32 have problems. limitation of address sanitizer? command line or runtime trick use work around issue?

edit: has nothing common blocks, fact arrays in common blocks allocated if never used. causes same problem:

      program main       implicit none *     real*8, allocatable :: aa(:) *     !allocate(aa(378272768)) *     allocate(aa(378272769))       !real*8 aa(50292702)       real*8 aa(50292705)       aa(1)=1.0d0       write(6,*) 'hello!'       end program main 

note limit allocatable array 8 times larger static array.

is limitation of address sanitizer?

indeed, on 32-bit linux asan needs free area @ 0x1ffff000-0x37ffffff it's shadow memory (see source code other platform ranges). conflicts large common arrays in program.

any command line or runtime trick use work around issue?

the address unfortunately hard-coded in compiler , runtime library (for performance reasons) i'm not sure can fix without changing code (e.g. dynamically allocating arrays?). or can stick 64-bit version of code asan testing (chance of conflicts lower there).

as side note - it's recommended not use common arrays asan (see faq) because prevent detection of buffer overflows in them (don't ask). can disable them -fno-common.


Comments