This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
target/9082: [alpha,ia64] memcpy makes unaligned access
- From: Matthias Klose <doko at debian dot org>
- To: gcc-gnats at gcc dot gnu dot org, debian-gcc at lists dot debian dot org
- Cc: Herbert Xu <herbert at gondor dot apana dot org dot au>
- Date: Sat, 28 Dec 2002 19:24:49 +0100
- Subject: target/9082: [alpha,ia64] memcpy makes unaligned access
- Reply-to: 85468 at bugs dot debian dot org, 169004 at bugs dot debian dot org
>Number: 9082
>Category: target
>Synopsis: [alpha,ia64] memcpy makes unaligned access
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Sat Dec 28 10:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Herbert Xu <herbert@gondor.apana.org.au>
>Release: 3.2.1 (Debian) (Debian unstable)
>Organization:
The Debian Project
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: alpha-linux, ia64-linux
host: alpha-linux
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.2 20021212 (Debian prerelease)
>Description:
[ Reported to the Debian BTS as report #85468, #169004
Please CC 85468@bugs.debian.org on replies.
Log of report can be found at
http://bugs.debian.org/85468 for alpha
http://bugs.debian.org/169004 for ia64
]
[ reported for 2.95.2, rechecked with gcc-3_2-branch 20021212, Debian
source code found at http://packages.debian.org/unstable/net/fping.html ]
Herbert Xu writes:
I attempted to make a minimal test case but failed as the stripped down
version actually produced the correct code.
The problem arose in fping. The relevant code is in fping.c:wait_for_reply(),
memcpy(&sent_time, icp->icmp_data + offsetof(PING_DATA, ping_ts),
sizeof(sent_time));
memcpy(&this_count, icp->icmp_data, sizeof(this_count));
Since icp->icmp_data is 4-byte aligned, one would expect the memcpys to do
five 4-byte loads. However, the actual assembly produced with
gcc -S -g -O2 is
$LM490:
.stabn 68,0,1157,$LM490
lds $f11,8($10)
$LM491:
.stabn 68,0,1155,$LM491
ldt $f10,16($10)
ldt $f12,24($10)
$LM492:
.stabn 68,0,1157,$LM492
sts $f11,80($30)
$LM493:
.stabn 68,0,1155,$LM493
stt $f10,88($30)
stt $f12,96($30)
Which causes two unaligned traps.
The followup for gcc-3.2:
It still happens with 3.2 branch 20021212 on alpha. This is the assembly:
26bc: 08 00 2a a0 ldl t0,8(s1)
26c0: 10 00 4a a4 ldq t1,16(s1)
26c4: 18 00 6a a4 ldq t2,24(s1)
26c8: 40 00 3e b0 stl t0,64(sp)
26cc: 48 00 5e b4 stq t1,72(sp)
26d0: 50 00 7e b4 stq t2,80(sp)
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: