public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41354]  New: g++: Inlining constructors puts wrong vtable in objects
@ 2009-09-14  8:56 erik at arbat dot com
  2009-09-14  9:00 ` [Bug c++/41354] " erik at arbat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: erik at arbat dot com @ 2009-09-14  8:56 UTC (permalink / raw)
  To: gcc-bugs

The GCC in Ubuntu Karmic for ARM uses the vtable of the superclass when
inlining the constructors of several subclasses in the same function.  This
happens only when using -fno-strict-aliasing.  This can cause the program to
fail with a "pure virtual called" error.  The V8 JavaScript engine is one
program that is vulnerable to this bug.

Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-3ubuntu3'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-objc-gc
--disable-sjlj-exceptions --with-arch=armv6 --with-tune=cortex-a8
--with-float=softfp --with-fpu=vfp --disable-werror --enable-checking=release
--build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-3ubuntu3)


-- 
           Summary: g++: Inlining constructors puts wrong vtable in objects
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: erik at arbat dot com
 GCC build triplet: arm-linux-gnueabi
  GCC host triplet: arm-linux-gnueabi
GCC target triplet: arm-linux-gnueabi


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


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

* [Bug c++/41354] g++: Inlining constructors puts wrong vtable in objects
  2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
@ 2009-09-14  9:00 ` erik at arbat dot com
  2009-09-14 15:01 ` [Bug middle-end/41354] " mikpe at it dot uu dot se
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: erik at arbat dot com @ 2009-09-14  9:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from erik at arbat dot com  2009-09-14 09:00 -------
Created an attachment (id=18581)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18581&action=view)
Test case.

The following file illustrates the bug.  Compiling with
g++ -O1 -fno-strict-aliasing -c codegen.cc
to see the bug.  Compile with
g++ -O1 -fno-strict-aliasing -fno-tree-sink -c codegen.cc
to make the bug go away.  If you disassemble the two versions you can see that
in the buggy version both instances get the same vtable.  In the correct
version the constant pool is one word larger, as the two instances have two
different vtables.


-- 


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


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

* [Bug middle-end/41354] g++: Inlining constructors puts wrong vtable in objects
  2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
  2009-09-14  9:00 ` [Bug c++/41354] " erik at arbat dot com
@ 2009-09-14 15:01 ` mikpe at it dot uu dot se
  2009-09-15 13:22 ` erik at arbat dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mikpe at it dot uu dot se @ 2009-09-14 15:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mikpe at it dot uu dot se  2009-09-14 15:01 -------
Incomplete test case, compiling w/o -c results in linkage errors:

codegen.cc:(.text+0x1a): undefined reference to `CodeStub::get_code()'
codegen.cc:(.text+0x30): undefined reference to `CodeStub::get_code()'
codegen.cc:(.text+0x4c): undefined reference to `printf(char const*, int, int)'

Please post a self-contained test case that can be linked and executed to
reproduce the "pure virtual called" error.

(Manually inspecting the output of objdump -d is a very inefficient way of
checking for the presence or absence of a bug.)


-- 


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


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

* [Bug middle-end/41354] g++: Inlining constructors puts wrong vtable in objects
  2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
  2009-09-14  9:00 ` [Bug c++/41354] " erik at arbat dot com
  2009-09-14 15:01 ` [Bug middle-end/41354] " mikpe at it dot uu dot se
@ 2009-09-15 13:22 ` erik at arbat dot com
  2009-09-17 13:23 ` mikpe at it dot uu dot se
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: erik at arbat dot com @ 2009-09-15 13:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from erik at arbat dot com  2009-09-15 13:22 -------
Created an attachment (id=18584)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18584&action=view)
Self-contained program demonstrating the issue.

Correct behaviour is to do nothing.
Incorrect behaviour is to crash with a pure virtual called error.


-- 

erik at arbat dot com changed:

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


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


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

* [Bug middle-end/41354] g++: Inlining constructors puts wrong vtable in objects
  2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
                   ` (2 preceding siblings ...)
  2009-09-15 13:22 ` erik at arbat dot com
@ 2009-09-17 13:23 ` mikpe at it dot uu dot se
  2009-09-17 16:18 ` mikpe at it dot uu dot se
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mikpe at it dot uu dot se @ 2009-09-17 13:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mikpe at it dot uu dot se  2009-09-17 13:23 -------
Confirmed with gcc-4.4.1 and gcc-4.3.4 on armv5tel-unknown-linux-gnueabi.
I've not been able to trigger it with gcc-4.4.1 on i686-linux, powerpc-linux,
or sparc64-solaris, so it looks ARM-specific.

I'll check if there's a fix upstream, or failing that, if I can identify the
commit that introduced the bug.


-- 


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


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

* [Bug middle-end/41354] g++: Inlining constructors puts wrong vtable in objects
  2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
                   ` (3 preceding siblings ...)
  2009-09-17 13:23 ` mikpe at it dot uu dot se
@ 2009-09-17 16:18 ` mikpe at it dot uu dot se
  2009-09-18  3:44 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mikpe at it dot uu dot se @ 2009-09-17 16:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mikpe at it dot uu dot se  2009-09-17 16:18 -------
Appears fixed in gcc-4.5-20090910, but not in gcc-4.4-20090915. I'll start a
binary search to see what fixed it (I have a suspicion already).


-- 


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


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

* [Bug middle-end/41354] g++: Inlining constructors puts wrong vtable in objects
  2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
                   ` (4 preceding siblings ...)
  2009-09-17 16:18 ` mikpe at it dot uu dot se
@ 2009-09-18  3:44 ` pinskia at gcc dot gnu dot org
  2009-09-18  7:19 ` ramana at gcc dot gnu dot org
  2009-09-18 11:15 ` mikpe at it dot uu dot se
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-09-18  3:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2009-09-18 03:43 -------
Does -fno-tree-sink fix the issue?  If so this is duplicate of bug 39604.


-- 


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


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

* [Bug middle-end/41354] g++: Inlining constructors puts wrong vtable in objects
  2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
                   ` (5 preceding siblings ...)
  2009-09-18  3:44 ` pinskia at gcc dot gnu dot org
@ 2009-09-18  7:19 ` ramana at gcc dot gnu dot org
  2009-09-18 11:15 ` mikpe at it dot uu dot se
  7 siblings, 0 replies; 9+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-09-18  7:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from ramana at gcc dot gnu dot org  2009-09-18 07:19 -------
(In reply to comment #6)
> Does -fno-tree-sink fix the issue?  If so this is duplicate of bug 39604.
> 

Comment #1 indicates that -fno-tree-sink fixes the issue. 

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


-- 

ramana at gcc dot gnu dot org changed:

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


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


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

* [Bug middle-end/41354] g++: Inlining constructors puts wrong vtable in objects
  2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
                   ` (6 preceding siblings ...)
  2009-09-18  7:19 ` ramana at gcc dot gnu dot org
@ 2009-09-18 11:15 ` mikpe at it dot uu dot se
  7 siblings, 0 replies; 9+ messages in thread
From: mikpe at it dot uu dot se @ 2009-09-18 11:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from mikpe at it dot uu dot se  2009-09-18 11:14 -------
The binary search identified revision 145494, the alias-improvements merge, as
the point where this test case stopped breaking.


-- 


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


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

end of thread, other threads:[~2009-09-18 11:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-14  8:56 [Bug c++/41354] New: g++: Inlining constructors puts wrong vtable in objects erik at arbat dot com
2009-09-14  9:00 ` [Bug c++/41354] " erik at arbat dot com
2009-09-14 15:01 ` [Bug middle-end/41354] " mikpe at it dot uu dot se
2009-09-15 13:22 ` erik at arbat dot com
2009-09-17 13:23 ` mikpe at it dot uu dot se
2009-09-17 16:18 ` mikpe at it dot uu dot se
2009-09-18  3:44 ` pinskia at gcc dot gnu dot org
2009-09-18  7:19 ` ramana at gcc dot gnu dot org
2009-09-18 11:15 ` mikpe at it dot uu dot se

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