All of lore.kernel.org
 help / color / mirror / Atom feed
From: Randolph Chung <randolph@tausq.org>
To: jsoe0708@tiscali.be
Cc: parisc-linux@lists.parisc-linux.org
Subject: Re: [parisc-linux] unaligned accesses
Date: Fri, 10 Jan 2003 08:29:07 -0800	[thread overview]
Message-ID: <20030110162906.GG31470@tausq.org> (raw)
In-Reply-To: <3E1AA8D5000009DC@ocpmta8.freegates.net>

> Unfortunately this doesn't reproduce the actual problem of which I save
> the following traces (from the evms_vgscan 1.1.0: once again this was fix
> since next release):

i'm not sure i correctly parsed what you wrote... the structure you
posted is fine, but that doesn't mean it cannot cause unaligned accesses
if used incorrectly.

for a simple example:
struct foo {
    int bar;
};

this structure if placed on the stack by gcc is always int-aligned. but
you can easily generate unaligned accesses from it:

void botch(void)
{
    char buf[1024];
    struct foo x;
    struct foo *a, *b;

    a = &x;
    b = (struct foo *)buf[2];

    printf("%d\n", a->bar); /* aligned */
    printf("%d\n", b->bar); /* unaligned! */
}

in this case, the structure gives you no guarantees that things will be
aligned properly.

it's also possible to have much more involved scenarios, (e.g. with
unions of things with different alignments), where things can get messed
up.... you need to carefully look at how the code works to debug these
things. while gcc may not be bug-free in this area, it's much more
likely to be an application bug than a gcc one.

randolph
-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/

  reply	other threads:[~2003-01-10 16:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-09  7:55 [parisc-linux] Printing problem with HP9000 712/80 and two more questions Vilmos Soti
2003-01-09  8:29 ` [parisc-linux] unaligned accesses Randolph Chung
2003-01-10  7:29   ` jsoe0708
2003-01-10  7:36     ` Randolph Chung
2003-01-10  8:24       ` jsoe0708
2003-01-10 12:52         ` Matthieu Delahaye
2003-01-10 13:45         ` jsoe0708
2003-01-10 16:29           ` Randolph Chung [this message]
2003-01-10 15:30         ` John David Anglin
2003-01-10 10:51       ` jsoe0708
2003-01-10 17:08         ` Matthew Wilcox
2003-01-10 18:47           ` jsoe0708
2003-01-10 22:13             ` Thibaut VARENE
2003-01-10 22:25               ` Thibaut VARENE
2003-01-12 15:25                 ` Joel Soete
2003-01-12 16:02                   ` Thibaut VARENE

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030110162906.GG31470@tausq.org \
    --to=randolph@tausq.org \
    --cc=jsoe0708@tiscali.be \
    --cc=parisc-linux@lists.parisc-linux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.