From: Oscar Levi <elf@buici.com>
To: axp-list@redhat.com
Subject: Re: How do I find/fix unaligned accesses?
Date: Sat, 5 Dec 1998 08:37:17 -0800 [thread overview]
Message-ID: <19981205083716.A1438@hazel.buici.com> (raw)
In-Reply-To: <Pine.ULT.3.91.981204182134.6659z-100000@gunn.kednos.com>; from Tom Linden on Fri, Dec 04, 1998 at 06:29:24PM -0800
On Fri, Dec 04, 1998 at 06:29:24PM -0800, Tom Linden wrote:
> This is generally the right approach, but having done this many times
> there is a bit more to do. Once you have breakpointed, you need to
> determine which variable is offending, and this generally means examing
> the assembler statements with gdb and relating it to the source. Once
> identified you need to find the declaration of the variable whether
> static or automatic, and by looking at the declaration trying to figure
> out how it got allocated on the inappropriate boundary. If it is this
> simple then padding by dummy allocations of the appropriate size will fix
> it. If however, this is the result of aliasing, this may require more
> difficult source code changes. use of 'nm' helps a lot. good luck.
AFAIK, the primary source of these aligned accesses are pointer
tricks. Writing structures and using malloc should not cause
unaligned acceses. Instead, these tend occur when authors cast
pointers of one type to another. For example, allocating untyped
memory and coercing the pointer into pointer pointer.
void* pv;
pv = malloc (CB_DATA);
char** ppch = (char**)((char*) pv + 1);
*ppch = "Hello"; Whoops!
Please correct me if I have gone astray. I don't believe it is
possible to generate unaligned accesses without performing pointer
arithmetic with casted pointers.
Why is this interesting? It can you help find the source of problems
when you know where the culprit hides.
Cheers.
next prev parent reply other threads:[~1998-12-05 16:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-04 18:25 How do I find/fix unaligned accesses? Eric Ding
1998-12-04 21:16 ` Oscar Levi
1998-12-04 21:17 ` nbecker
1998-12-04 21:18 ` Harvey J. Stein
1998-12-04 21:35 ` Rich Payne
1998-12-05 2:29 ` Tom Linden
1998-12-05 16:37 ` Oscar Levi [this message]
1998-12-07 23:45 ` Eric Ding
1998-12-08 0:44 ` Richard Hadsell
1998-12-08 1:07 ` Uncle George
1998-12-08 3:58 ` Eric Ding
1998-12-08 7:16 ` Wes Bauske
1998-12-08 11:14 ` Uncle George
1998-12-08 13:04 ` nbecker
-- strict thread matches above, loose matches on Subject: below --
1998-12-08 21:13 Christian Groessler
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox