public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc
@ 2011-05-12 16:29 d.g.gorbachev at gmail dot com
  2011-05-12 18:52 ` [Bug other/48981] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-05-12 16:29 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: bootstrap-lto -O3 produces miscompiled, broken gcc
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: d.g.gorbachev@gmail.com
                CC: rguenth@gcc.gnu.org
              Host: i686-pc-linux-gnu
            Target: i686-pc-linux-gnu
             Build: i686-pc-linux-gnu


GCC crashes because of violation of strict aliasing rules. The same memory
location is accessed in vec_gc_o_reserve_1 through (struct vec_prefix *)
pointer, then in VEC_tree_base_quick_push through (struct VEC_tree_base *).
Optimization moves the code around in a wrong way.

This patch fixes it:

--- gcc/vec.c
+++ gcc/vec.c
@@ -37,11 +37,11 @@
 struct vec_prefix
 {
   unsigned num;
   unsigned alloc;
   void *vec[1];
-};
+} __attribute__ ((may_alias));


 #ifdef GATHER_STATISTICS

 /* Store information about each particular vector.  */


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
@ 2011-05-12 18:52 ` pinskia at gcc dot gnu.org
  2011-05-13  9:11 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-05-12 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-05-12 17:59:56 UTC ---
Created attachment 24239
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24239
Patch which changes how vec base is done

Can you try this patch?  I have not tested it and have not even tried compiling
it.


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
  2011-05-12 18:52 ` [Bug other/48981] " pinskia at gcc dot gnu.org
@ 2011-05-13  9:11 ` rguenth at gcc dot gnu.org
  2011-05-13 21:27 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-13  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.05.13 08:36:35
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-13 08:36:35 UTC ---
Confirmed.  A patch similar to Andrews should work.


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
  2011-05-12 18:52 ` [Bug other/48981] " pinskia at gcc dot gnu.org
  2011-05-13  9:11 ` rguenth at gcc dot gnu.org
@ 2011-05-13 21:27 ` pinskia at gcc dot gnu.org
  2011-05-13 21:57 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-05-13 21:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-05-13 21:22:18 UTC ---
(In reply to comment #2)
> Confirmed.  A patch similar to Andrews should work.

I will attach a patch which actually compiles :).


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
                   ` (2 preceding siblings ...)
  2011-05-13 21:27 ` pinskia at gcc dot gnu.org
@ 2011-05-13 21:57 ` pinskia at gcc dot gnu.org
  2011-05-14  2:01 ` d.g.gorbachev at gmail dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-05-13 21:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24239|0                           |1
        is obsolete|                            |

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-05-13 21:23:56 UTC ---
Created attachment 24244
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24244
new patch which actually compiles but not has been fully tested


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
                   ` (3 preceding siblings ...)
  2011-05-13 21:57 ` pinskia at gcc dot gnu.org
@ 2011-05-14  2:01 ` d.g.gorbachev at gmail dot com
  2011-05-25  1:24 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-05-14  2:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2011-05-14 00:51:44 UTC ---
(In reply to comment #4)

Then this comment in gengtype.c becomes no longer valid, and confusing:

   /* Record the definition of a generic VEC structure, as if we had expanded
      the macros in vec.h:

>     typedef struct VEC_<type>_base GTY(()) {
>     unsigned num;
>     unsigned alloc;
> -   <type> GTY((length ("%h.num"))) vec[1];
> +   <type> GTY((length ("%h.prefix.num"))) vec[1];
>     } VEC_<type>_base
>
>     where the GTY(()) tags are only present if is_scalar is _false_.  */

In vec.h:

> +#ifndef GTY
> +#define GTY(x)  /* nothing - marker for gengtype */
> +#endif

It could be fixed by changing the #include order in vec.c:

 #include "system.h"
+#include "coretypes.h"
 #include "ggc.h"
 #include "vec.h"
-#include "coretypes.h"
 #include "diagnostic-core.h"
 #include "hashtab.h"


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
                   ` (4 preceding siblings ...)
  2011-05-14  2:01 ` d.g.gorbachev at gmail dot com
@ 2011-05-25  1:24 ` pinskia at gcc dot gnu.org
  2011-05-27 15:08 ` d.g.gorbachev at gmail dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-05-25  1:24 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24244|0                           |1
        is obsolete|                            |
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |pinskia at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-05-25 00:57:24 UTC ---
Created attachment 24352
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24352
new patch which I am testing right now

Here is the new patch which fixes up gengtype issue.  I am going to submit it
tomorrow after my testresults finish.


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
                   ` (5 preceding siblings ...)
  2011-05-25  1:24 ` pinskia at gcc dot gnu.org
@ 2011-05-27 15:08 ` d.g.gorbachev at gmail dot com
  2011-05-27 20:20 ` pinskia at gcc dot gnu.org
  2011-05-27 20:22 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-05-27 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2011-05-27 15:00:04 UTC ---
(In reply to comment #6)

I think there should be a space after "}" in vec.h:

> +}vec_prefix;

Thanks!


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
                   ` (6 preceding siblings ...)
  2011-05-27 15:08 ` d.g.gorbachev at gmail dot com
@ 2011-05-27 20:20 ` pinskia at gcc dot gnu.org
  2011-05-27 20:22 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-05-27 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-05-27 20:19:16 UTC ---
Author: pinskia
Date: Fri May 27 20:19:13 2011
New Revision: 174359

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174359
Log:
2011-05-27  Andrew Pinski  <pinskia@gmail.com>

    PR middle-end/48981
    * gengtype.c (vec_prefix_type): New function.
    (note_def_vec): Use vec_prefix_type and change the length
    attribute to be based on the prefix.
    * vec.c: Include coretypes.h before vec.h.
    (struct vec_prefix): Remove.
    (vec_gc_p_reserve): Change the offsetof to sizeof.
    (vec_gc_p_reserve_exact): Likewise.
    (vec_heap_p_reserve): Likewise.
    (vec_heap_p_reserve_exact): Likewise.
    (vec_stack_o_reserve_1): Copy from +1 instead of from vec.
    (vec_stack_p_reserve): Change the offsetof to sizeof.
    (vec_stack_p_reserve_exact): Likewise.
    * vec.h (struct vec_prefix): New struct definition.
    (VEC_T(T,B)): Use vec_prefix instead of having num/alloc fields.
    (VEC_T_GTY(T,B)): Likewise.
    (DEF_VEC_FUNC_P(T)): Use prefix field.
    (DEF_VEC_NONALLOC_FUNCS_O(T,A)): Likewise.
    (DEF_VEC_NONALLOC_FUNCS_I(T,A)): Likewise.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gengtype.c
    trunk/gcc/vec.c
    trunk/gcc/vec.h


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

* [Bug other/48981] bootstrap-lto -O3 produces miscompiled, broken gcc
  2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
                   ` (7 preceding siblings ...)
  2011-05-27 20:20 ` pinskia at gcc dot gnu.org
@ 2011-05-27 20:22 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-05-27 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-05-27 20:20:19 UTC ---
Fixed.


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

end of thread, other threads:[~2011-05-27 20:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12 16:29 [Bug other/48981] New: bootstrap-lto -O3 produces miscompiled, broken gcc d.g.gorbachev at gmail dot com
2011-05-12 18:52 ` [Bug other/48981] " pinskia at gcc dot gnu.org
2011-05-13  9:11 ` rguenth at gcc dot gnu.org
2011-05-13 21:27 ` pinskia at gcc dot gnu.org
2011-05-13 21:57 ` pinskia at gcc dot gnu.org
2011-05-14  2:01 ` d.g.gorbachev at gmail dot com
2011-05-25  1:24 ` pinskia at gcc dot gnu.org
2011-05-27 15:08 ` d.g.gorbachev at gmail dot com
2011-05-27 20:20 ` pinskia at gcc dot gnu.org
2011-05-27 20:22 ` pinskia at gcc dot gnu.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).