[Bug target/59679] gcc version 4.7.3 and gcc version 4.5.3 cause an unaligned access exception on NetBSD/Alpha

mcree at orcon dot net.nz gcc-bugzilla@gcc.gnu.org
Sun Jan 26 22:56:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59679

Michael Cree <mcree at orcon dot net.nz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mcree at orcon dot net.nz

--- Comment #10 from Michael Cree <mcree at orcon dot net.nz> ---
This misaligned access in perl is also seen on Debian Alpha Linux. I have been
able to reduce the scope.c file substantially while maintaining the misaligned
access.  I will attach that as scope-reduced.c.

The misaligned access occurs in line 60, being the case SAVEt_I8 of the switch
statement, and with -O2 compiles to:

        extbl $4,1,$4
$LVL18:
        ldl $1,0($6)
        bic $1,255,$1
        bis $4,$1,$4
        stl $4,0($6)

Thus there is an assumption that ARG0_PTR (which expands to arg0.any_ptr)
points to an address at least divisible by four.

If one compiles with -fno-tree-ter as mentioned in the initial bug report then
one gets:

        sll $5,48,$5
$LVL18:
        ldq_u $1,0($4)
        sra $5,56,$5
        mskbl $1,$4,$1
        insbl $5,$4,$5
        bis $5,$1,$5
        stq_u $5,0($4)

which copes with any alignment.

If either of the cases SAVEt_SAVESWITCHSTACK or SAVEt_SET_SVFLAGS is removed
from the switch statement then the ldq_u/mskbl/insbl sequence results. Thus
there appears to be some interaction between those two cases and the code at
the top of the while statement that the compiler is using to determine that
ARG0_PTR points to an address at least divisible by four.  I admit that I have
so far failed to see how such an inference can be made but look forward to
being educated by the erudite gcc maintainers.

Compilation was done with:

cc -DPERL_CORE  -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -D_FORTIFY_SOURCE=2 -g -O2
-v -S scope-reduced.c
Using built-in specs.
COLLECT_GCC=cc
Target: alpha-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.8.2-13'
--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-libssp
--disable-libmudflap --disable-libitm --disable-libsanitizer
--disable-libquadmath --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-alpha/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-alpha
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-alpha
--with-arch-directory=alpha --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-long-double-128
--enable-checking=release --build=alpha-linux-gnu --host=alpha-linux-gnu
--target=alpha-linux-gnu
Thread model: posix
gcc version 4.8.2 (Debian 4.8.2-13) 
COLLECT_GCC_OPTIONS='-D' 'PERL_CORE' '-D' '_REENTRANT' '-D' '_GNU_SOURCE' '-D'
'DEBIAN' '-D' '_FORTIFY_SOURCE=2' '-g' '-O2' '-v' '-S'
 /usr/lib/gcc/alpha-linux-gnu/4.8/cc1 -quiet -v -imultilib . -imultiarch
alpha-linux-gnu -D PERL_CORE -D _REENTRANT -D _GNU_SOURCE -D DEBIAN -D
_FORTIFY_SOURCE=2 scope-reduced.c -quiet -dumpbase scope-reduced.c -auxbase
scope-reduced -g -O2 -version -o scope-reduced.s
GNU C (Debian 4.8.2-13) version 4.8.2 (alpha-linux-gnu)
    compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/alpha-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/alpha-linux-gnu/4.8/../../../../alpha-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/alpha-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/alpha-linux-gnu/4.8/include-fixed
 /usr/include/alpha-linux-gnu
 /usr/include
End of search list.
GNU C (Debian 4.8.2-13) version 4.8.2 (alpha-linux-gnu)
    compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 503630c10eca9d1ddabc1e36fce68a5f
COMPILER_PATH=/usr/lib/gcc/alpha-linux-gnu/4.8/:/usr/lib/gcc/alpha-linux-gnu/4.8/:/usr/lib/gcc/alpha-linux-gnu/:/usr/lib/gcc/alpha-linux-gnu/4.8/:/usr/lib/gcc/alpha-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/alpha-linux-gnu/4.8/:/usr/lib/gcc/alpha-linux-gnu/4.8/../../../alpha-linux-gnu/:/usr/lib/gcc/alpha-linux-gnu/4.8/../../../:/lib/alpha-linux-gnu/:/lib/:/usr/lib/alpha-linux-gnu/:/usr/lib/
COLLECT_GCC_OPTIONS='-D' 'PERL_CORE' '-D' '_REENTRANT' '-D' '_GNU_SOURCE' '-D'
'DEBIAN' '-D' '_FORTIFY_SOURCE=2' '-g' '-O2' '-v' '-S'

I will also attach preprocessed source.



More information about the Gcc-bugs mailing list