public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/56561] New: Miscompilation with -Os -arm
@ 2013-03-07 12:47 mh+gcc at glandium dot org
  2013-03-07 13:38 ` [Bug target/56561] " mikpe at it dot uu.se
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mh+gcc at glandium dot org @ 2013-03-07 12:47 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56561
           Summary: Miscompilation with -Os -arm
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mh+gcc@glandium.org


Created attachment 29609
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29609
Testcase

(originally posted on http://gcc.gnu.org/ml/gcc/2013-03/msg00051.html)

At Mozilla, we've encountered a GCC 4.6 miscompilation in the ARMv6
build of Firefox for Android. We'd like to evaluate whether this bug is
hitting us in more places than the one we spotted. To that end, we'd
need to know what particular bug in GCC leads to this miscompilation.

The attached file is the preprocessed source, slightly simplified, and with
enough additions to allow it to be self-contained and with a main() that is
able to act on the miscompilation being there or not.

I was able to reproduce the miscompilation with both the GCC 4.6 from the
Android NDK r8d and 4.6.3 from Debian unstable. It apparently happens
for any -march, with -marm, but not -mthumb. It happens at -Os but not
-O2.

The problematic assembly looks like the following. It corresponds to
the C code after the second call to DER_SetUInteger in sftk_mkPrivKey::

  bl      DER_SetUInteger(PLT)
  mov     r3, #0
  cmp     sl, r3
  movne   r0, #2
  moveq   r0, r3

sl/r10 is never set anywhere in the function, so we're getting random
behaviour.

This doesn't happen with GCC 4.7, which suggests it may be a known bug.
Any ideas?

(On an ARM host:)
$ gcc -o pkcs11 pkcs11.i -marm -Os -fno-inline
./pkcs11
$ ./pkcs11
FAIL
$ gcc -o pkcs11 pkcs11.i -marm -O2 -fno-inline
./pkcs11
$ ./pkcs11
PASS


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/56561] Miscompilation with -Os -arm
  2013-03-07 12:47 [Bug target/56561] New: Miscompilation with -Os -arm mh+gcc at glandium dot org
@ 2013-03-07 13:38 ` mikpe at it dot uu.se
  2013-03-07 18:15 ` mikpe at it dot uu.se
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mikpe at it dot uu.se @ 2013-03-07 13:38 UTC (permalink / raw)
  To: gcc-bugs


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

Mikael Pettersson <mikpe at it dot uu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu.se

--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> 2013-03-07 13:37:51 UTC ---
I can reproduce the runtime failure on armv5tel-linux-gnueabi with vanilla
gcc-4.6.3.  Trunk works, as does my heavily patched 4.6-based system compiler.
I'll investigate some more later today.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/56561] Miscompilation with -Os -arm
  2013-03-07 12:47 [Bug target/56561] New: Miscompilation with -Os -arm mh+gcc at glandium dot org
  2013-03-07 13:38 ` [Bug target/56561] " mikpe at it dot uu.se
@ 2013-03-07 18:15 ` mikpe at it dot uu.se
  2013-03-08  8:00 ` sebastian.huber@embedded-brains.de
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mikpe at it dot uu.se @ 2013-03-07 18:15 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Mikael Pettersson <mikpe at it dot uu.se> 2013-03-07 18:14:17 UTC ---
The wrong-code on 4.6 branch is stopped by backporting r183512 aka PR48308 fix.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/56561] Miscompilation with -Os -arm
  2013-03-07 12:47 [Bug target/56561] New: Miscompilation with -Os -arm mh+gcc at glandium dot org
  2013-03-07 13:38 ` [Bug target/56561] " mikpe at it dot uu.se
  2013-03-07 18:15 ` mikpe at it dot uu.se
@ 2013-03-08  8:00 ` sebastian.huber@embedded-brains.de
  2013-03-08  8:24 ` mikpe at it dot uu.se
  2013-03-10  9:20 ` mh+gcc at glandium dot org
  4 siblings, 0 replies; 6+ messages in thread
From: sebastian.huber@embedded-brains.de @ 2013-03-08  8:00 UTC (permalink / raw)
  To: gcc-bugs


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

Sebastian Huber <sebastian.huber@embedded-brains.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sebastian.huber@embedded-br
                   |                            |ains.de

--- Comment #3 from Sebastian Huber <sebastian.huber@embedded-brains.de> 2013-03-08 07:59:54 UTC ---
The arm-eabi target is also affected by this bug.

(In reply to comment #2)
> The wrong-code on 4.6 branch is stopped by backporting r183512 aka PR48308 fix.

Is there a back port available as a patch?  A simple "git cherry-pick
eed2904aa7a3ce889e8a0dd8e7ec59f9190ce5fe" in the 4.6 branch does not work due
to undefined references to "alloc_insn_link".


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/56561] Miscompilation with -Os -arm
  2013-03-07 12:47 [Bug target/56561] New: Miscompilation with -Os -arm mh+gcc at glandium dot org
                   ` (2 preceding siblings ...)
  2013-03-08  8:00 ` sebastian.huber@embedded-brains.de
@ 2013-03-08  8:24 ` mikpe at it dot uu.se
  2013-03-10  9:20 ` mh+gcc at glandium dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mikpe at it dot uu.se @ 2013-03-08  8:24 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Mikael Pettersson <mikpe at it dot uu.se> 2013-03-08 08:23:31 UTC ---
Created attachment 29613
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29613
backport of r183512/PR48308 to 4.6 branch

This is the backport I've been using since early June 2012.  The original patch
required adjustments related to how LOG_LINKS are stored.  Tested extensively
on x86_64, sparc64, powerpc64, armv5te, and m68k.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/56561] Miscompilation with -Os -arm
  2013-03-07 12:47 [Bug target/56561] New: Miscompilation with -Os -arm mh+gcc at glandium dot org
                   ` (3 preceding siblings ...)
  2013-03-08  8:24 ` mikpe at it dot uu.se
@ 2013-03-10  9:20 ` mh+gcc at glandium dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mh+gcc at glandium dot org @ 2013-03-10  9:20 UTC (permalink / raw)
  To: gcc-bugs


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

Mike Hommey <mh+gcc at glandium dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #5 from Mike Hommey <mh+gcc at glandium dot org> 2013-03-10 09:20:05 UTC ---
Thanks for tracking it down.

*** This bug has been marked as a duplicate of bug 48308 ***


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-03-10  9:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-07 12:47 [Bug target/56561] New: Miscompilation with -Os -arm mh+gcc at glandium dot org
2013-03-07 13:38 ` [Bug target/56561] " mikpe at it dot uu.se
2013-03-07 18:15 ` mikpe at it dot uu.se
2013-03-08  8:00 ` sebastian.huber@embedded-brains.de
2013-03-08  8:24 ` mikpe at it dot uu.se
2013-03-10  9:20 ` mh+gcc at glandium dot org

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).