Bug 9082 - [alpha,ia64] memcpy makes unaligned access
Summary: [alpha,ia64] memcpy makes unaligned access
Status: RESOLVED DUPLICATE of bug 9080
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.2.1
: P3 normal
Target Milestone: ---
Assignee: Richard Henderson
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2002-12-28 10:26 UTC by 85468, 169004
Modified: 2003-06-12 00:15 UTC (History)
3 users (show)

See Also:
Host: alpha-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 85468, 169004 2002-12-28 10:26:01 UTC
[ 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)

Release:
3.2.1 (Debian) (Debian unstable)

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)
Comment 1 Richard Henderson 2003-01-26 10:22:31 UTC
*** This bug has been marked as a duplicate of 9080 ***
Comment 2 herbert 2003-01-26 21:45:30 UTC
From: Herbert Xu <herbert@gondor.apana.org.au>
To: rth@gcc.gnu.org, 169004@bugs.debian.org, 85468@bugs.debian.org,
	gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org,
	gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: target/9082: [alpha,ia64] memcpy makes unaligned access
Date: Sun, 26 Jan 2003 21:45:30 +1100

 On Sun, Jan 26, 2003 at 10:22:31AM -0000, rth@gcc.gnu.org wrote:
 > Synopsis: [alpha,ia64] memcpy makes unaligned access
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: rth
 > State-Changed-When: Sun Jan 26 10:22:31 2003
 > State-Changed-Why:
 >     When submitting bugs to gcc, one must include the test case,
 >     not reference it in some package elsewhere.  This reduces the
 >     possibility that the bug requires specific system headers to
 >     be reproduced.
 
 I'm sorry about that, I'll get the preprocessed program sent to you.
 
 >     That said, it's obvious this is a duplicate of PR 9080,
 >     which is closed due to the input program being invalid.
 
 I'm afraid I don't see the connection between the two reports.
 In my case, memcpy is correct programmatically but it's triggering
 an alignment error as it's performing 8-byte loads when the source
 argument is 4-byte aligned (the destination is 8-byte aligned though).
 -- 
 Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
 Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
 Home Page: http://gondor.apana.org.au/~herbert/
 PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt