public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jk@tools.de
To: gcc-gnats@gcc.gnu.org
Subject: c/7847: pragma pack / attribute(packed): unaligned access to packed structure on SPARC
Date: Fri, 06 Sep 2002 05:26:00 -0000	[thread overview]
Message-ID: <20020906122324.12508.qmail@sources.redhat.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3327 bytes --]


>Number:         7847
>Category:       c
>Synopsis:       pragma pack / attribute(packed): unaligned access to packed structure on SPARC
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 06 05:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jürgen Keil
>Release:        gcc-3.2
>Organization:
>Environment:
Solaris 8 SPARC (also seen on Debian GNU/Linux 3.0)

Problem observed at least with gcc3.2, gcc3.1 and gcc2.95.X:

Reading specs from /usr/local/gcc-3.2/lib/gcc-lib/sparc-sun-solaris2.8/3.2/specs
Configured with: ../gcc-3.2/configure --enable-languages=c,c++ --prefix=/usr/local/gcc-3.2
Thread model: posix
gcc version 3.2

Reading specs from /opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/specs
gcc version 2.95.3 20010315 (release)

Reading specs from /usr/lib/gcc-lib/sparc-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
>Description:
GCC generates wrong code to access packed structure members
on the SPARC architecture.

A 32-bit load instruction is used to read from an unaligned
address inside a packed structure.  This is not allowed on the
SPARC architecture and the process terminates with a SIGBUS 
signal.
>How-To-Repeat:
Compile and run the attached test case

% gcc -o open3 open3.c
% ./open3
Bus error (core dumped)

Expected result:  the program should run without getting
a SIGBUS signal.

The crash happens while evaluating the |if (...)|
expression in function dvd_read_sector.  A 32-bit load
instruction is used to access the |.address| member from an 
unaligned address.

( Note:  when the member |a| inside the structure
|dvd_priv_t| is deleted, the generated code is OK; the
unaligned / packed structure is read using four byte loads.
These four bytes are assembled using 'shift' and 'or'
operations into a 32-bit value. )
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="open3.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="open3.c"

dHlwZWRlZiBjaGFyIGludDhfdDsKdHlwZWRlZiBzaG9ydCBpbnQxNl90Owp0eXBlZGVmIGludCBp
bnQzMl90Owp0eXBlZGVmIHVuc2lnbmVkIGNoYXIgdWludDhfdDsKdHlwZWRlZiB1bnNpZ25lZCBz
aG9ydCB1aW50MTZfdDsKdHlwZWRlZiB1bnNpZ25lZCBpbnQgdWludDMyX3Q7CgoKI2lmbmRlZiBf
X0dOVUNfXwojZGVmaW5lIF9fYXR0cmlidXRlX18oeCkKI3ByYWdtYSBwYWNrKDIpCiNlbmRpZgoK
dHlwZWRlZiBzdHJ1Y3QgewogICAgdWludDMyX3QgYWRkcmVzczsKICAgIHVpbnQxNl90IHNpemU7
Cn0gX19hdHRyaWJ1dGVfXyAoKHBhY2tlZCkpIHNtbF9hZ2xfZGF0YV90OwoKCnR5cGVkZWYgc3Ry
dWN0IHsKICBzbWxfYWdsX2RhdGFfdCBkYXRhWzldOwp9IF9fYXR0cmlidXRlX18gKChwYWNrZWQp
KSBzbWxfYWdsaV90OwoKCnR5cGVkZWYgc3RydWN0IHsKICBzbWxfYWdsaV90IHNtbF9hZ2xpOwp9
IF9fYXR0cmlidXRlX18gKChwYWNrZWQpKSBkc2lfdDsKCiNpZm5kZWYgX19HTlVDX18KI3ByYWdt
YSBwYWNrKCkKI2VuZGlmCgoKdHlwZWRlZiBzdHJ1Y3QgewogIGludCBhOwogIGRzaV90IGRzaV9w
YWNrOwp9IGR2ZF9wcml2X3Q7CgoKCmludApkdmRfcmVhZF9zZWN0b3IoZHZkX3ByaXZfdCAqZCx1
bnNpZ25lZCBjaGFyKiBkYXRhKQp7CiAgICBpbnQgaSxza2lwPTA7CiAgICAKICAgIGZvciAoaT0w
OyBpIDwgOTsgaSsrKQoJaWYgKChza2lwPWQtPmRzaV9wYWNrLnNtbF9hZ2xpLmRhdGFbaV0uYWRk
cmVzcykgIT0gMCkKCSAgICBicmVhazsKCiAgICByZXR1cm4gc2tpcDsKfQoKCm1haW4oKQp7CiAg
ICBzdGF0aWMgZHZkX3ByaXZfdCBkdmRfcHJpdjsKICAgIGR2ZF9yZWFkX3NlY3RvcigmZHZkX3By
aXYsIDApOwp9Cg==


                 reply	other threads:[~2002-09-06 12:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20020906122324.12508.qmail@sources.redhat.com \
    --to=jk@tools.de \
    --cc=gcc-gnats@gcc.gnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).