public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bernd.edlinger at hotmail dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/56997] Incorrect write to packed field when strict-volatile-bitfields enabled on aarch32
Date: Sun, 23 Jun 2013 18:02:00 -0000	[thread overview]
Message-ID: <bug-56997-4-CF9apqmZv5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56997-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56997

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bernd.edlinger at hotmail dot de

--- Comment #6 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Sandra Loosemore from comment #5)
> Patch posted here:

http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00750.html

Hi Sandra,

I tried your patch, but I dont like the code that it generates:

    printf("%x\n", (unsigned int)g.b);
    g.b = 0xAAAAAAA;

is compiled to invalid code (in ARMv5)

        ldr     r4, .L2
        ldr     r1, [r4]
        ldr     r3, [r4, #4]
        and     r3, r3, #7
        mov     r3, r3, asl #25
        orr     r1, r3, r1, lsr #7
        ldr     r0, .L2+4
        bl      printf
        ldr     r2, [r4]
        ldr     r3, .L2+8
        and     r2, r2, #127
        orr     r3, r2, r3
        str     r3, [r4]
        ldr     r3, [r4, #4]
        bic     r3, r3, #7
        orr     r3, r3, #5
        str     r3, [r4, #4]

code is invalid because: the object "g" is only 5 bytes large,
but the first statement reads 2x4 bytes, and ignores the 3 extra bytes.
this can fault if g is close to a segment boundary.
The second statement reads the 3 bytes beyond g and writes them
unmodified back. That is problematic if a task switch occurs between the
read and store sequence, and the other task modifies something in the 3 bytes.

Previous versions of gcc produced single 5x1 byte read/write sequences for
that structure, as does apparently the x86 version.

Regards
Bernd.


  parent reply	other threads:[~2013-06-23 18:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-18  8:05 [Bug target/56997] New: " joey.ye at arm dot com
2013-04-18  8:12 ` [Bug target/56997] " joey.ye at arm dot com
2013-04-18  8:26 ` rguenth at gcc dot gnu.org
2013-04-18  8:46 ` joey.ye at arm dot com
2013-06-08 19:59 ` sandra at codesourcery dot com
2013-06-14  3:01 ` sandra at codesourcery dot com
2013-06-23 18:02 ` bernd.edlinger at hotmail dot de [this message]
2013-06-23 22:03 ` bernd.edlinger at hotmail dot de
2013-06-24  0:03 ` sandra at codesourcery dot com
2013-06-24 20:27 ` bernd.edlinger at hotmail dot de
2013-06-25 11:35 ` bernd.edlinger at hotmail dot de
2013-08-28 20:43 ` ramana at gcc dot gnu.org
2013-10-07 15:42 ` sandra at codesourcery dot com
2013-12-11 16:50 ` edlinger at gcc dot gnu.org
2013-12-11 16:59 ` edlinger at gcc dot gnu.org
2014-01-07 10:12 ` joey.ye at arm dot com
2014-02-27  7:28 ` jye2 at gcc dot gnu.org
2014-08-15  4:46 ` pinskia at gcc dot gnu.org
2014-08-15 16:36 ` bernd.edlinger at hotmail dot de
2015-04-04 15:28 ` bernd.edlinger at hotmail dot de

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=bug-56997-4-CF9apqmZv5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).