public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault
@ 2011-02-24  7:13 isahib at xtra dot co.nz
  2011-02-25 10:50 ` [Bug c++/47873] " redi at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: isahib at xtra dot co.nz @ 2011-02-24  7:13 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Multiple Inheritance - Covariant Virtual Function -
                    Segfault
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: isahib@xtra.co.nz


Created attachment 23448
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23448
gcc-4.6 -save-temps output, demos bug

The attached BugReport.ii demos a reproducible bug in a complex multiple
inheritance scheme. When the covariant virtual function BugReport::Object::This
is overridden and called in a derived class then the program segfaults.

ggc-4.6 -v
==========
Using built-in specs.
COLLECT_GCC=gcc-4.6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6-20110216-1'
--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --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.6 --libdir=/usr/lib --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold
--enable-objc-gc --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.0 20110216 (experimental) [trunk revision 170225] (Debian
4.6-20110216-1)

gcc-4.6 build command line
==========================
-std=c++0x -Wall -Wextra -pedantic -g -save-temps

Shell output
============
Segmentation fault

Gdb output
==========
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()


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

* [Bug c++/47873] Multiple Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
@ 2011-02-25 10:50 ` redi at gcc dot gnu.org
  2011-02-25 11:18 ` redi at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2011-02-25 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-25 10:47:00 UTC ---
do you think you could make the example more confusing? maybe if you named
every namespace, class and member function the same, instead of only doing that
for most of them? ;)


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

* [Bug c++/47873] Multiple Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
  2011-02-25 10:50 ` [Bug c++/47873] " redi at gcc dot gnu.org
@ 2011-02-25 11:18 ` redi at gcc dot gnu.org
  2011-02-25 12:09 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2011-02-25 11:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-25 11:08:07 UTC ---
this doesn't segfault with 4.5

I have a reduced version with no stdlib or c++0x dependencies, and with less
confusing naming - will attach shortly


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

* [Bug c++/47873] Multiple Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
  2011-02-25 10:50 ` [Bug c++/47873] " redi at gcc dot gnu.org
  2011-02-25 11:18 ` redi at gcc dot gnu.org
@ 2011-02-25 12:09 ` redi at gcc dot gnu.org
  2011-02-25 12:35 ` [Bug c++/47873] [4.6 Regression] " redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2011-02-25 12:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-25 11:37:37 UTC ---
Created attachment 23465
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23465
reduced testcase

reduced testcase which removes c++0x and libstdc++ dependencies, removes the
java-style access control, re-indents and renames some of the identically-named
namespaces, classes and function to make it slightly more readable


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

* [Bug c++/47873] [4.6 Regression] Multiple Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (2 preceding siblings ...)
  2011-02-25 12:09 ` redi at gcc dot gnu.org
@ 2011-02-25 12:35 ` redi at gcc dot gnu.org
  2011-02-25 13:33 ` [Bug c++/47873] [4.6 Regression] virtual " redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2011-02-25 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.02.25 11:38:32
            Summary|Multiple Inheritance -      |[4.6 Regression] Multiple
                   |Covariant Virtual Function  |Inheritance - Covariant
                   |- Segfault                  |Virtual Function - Segfault
     Ever Confirmed|0                           |1

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-25 11:38:32 UTC ---
confirmed, no crash with 4.5 or earlier


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (3 preceding siblings ...)
  2011-02-25 12:35 ` [Bug c++/47873] [4.6 Regression] " redi at gcc dot gnu.org
@ 2011-02-25 13:33 ` redi at gcc dot gnu.org
  2011-02-26 19:59 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2011-02-25 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|[4.6 Regression] Multiple   |[4.6 Regression] virtual
                   |Inheritance - Covariant     |Inheritance - Covariant
                   |Virtual Function - Segfault |Virtual Function - Segfault

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-25 13:07:26 UTC ---
minimal testcase with no namespaces or multiple inheritance

the segfault goes away if Ent is an empty class or if virtual inheritance isn't
used


struct Base
{
    virtual ~Base(){}

    virtual Base& This() { return *this; }
};


struct Ent : virtual Base
{
    void *m_Body;

    Ent& This() { return *this; }

    virtual Ent& body()
    {
        return This();
    }

};


struct Msg : virtual Ent
{
    Msg()
    {
        body();
    }

    Msg& This() { return *this; }
};

int main()
{
    Msg m;

    return 0;
}

miscompiled by gcc-4.6-20110219 snapshot

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000000004007ff in Ent::body (this=0x7fffffffe598) at bug.cc:17
#2  0x00000000004009ca in Msg::Msg (this=0x7fffffffe590,
    __in_chrg=<value optimized out>, __vtt_parm=<value optimized out>)
    at bug.cc:27
#3  0x0000000000400719 in main () at bug.cc:35


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (4 preceding siblings ...)
  2011-02-25 13:33 ` [Bug c++/47873] [4.6 Regression] virtual " redi at gcc dot gnu.org
@ 2011-02-26 19:59 ` redi at gcc dot gnu.org
  2011-02-27 19:31 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2011-02-26 19:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-26 19:45:08 UTC ---
*** Bug 47874 has been marked as a duplicate of this bug. ***


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (5 preceding siblings ...)
  2011-02-26 19:59 ` redi at gcc dot gnu.org
@ 2011-02-27 19:31 ` jason at gcc dot gnu.org
  2011-02-28  6:53 ` isahib at xtra dot co.nz
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2011-02-27 19:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2011-02-27 17:12:45 UTC ---
Looking.


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (6 preceding siblings ...)
  2011-02-27 19:31 ` jason at gcc dot gnu.org
@ 2011-02-28  6:53 ` isahib at xtra dot co.nz
  2011-02-28  7:48 ` isahib at xtra dot co.nz
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: isahib at xtra dot co.nz @ 2011-02-28  6:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Ibaidul Sahib <isahib at xtra dot co.nz> 2011-02-28 06:39:39 UTC ---
Confirmed that this testcase runs fine with gcc 4.4.5/4.5.2

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47874 still fails on gcc
4.4.5/4.5.2


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (7 preceding siblings ...)
  2011-02-28  6:53 ` isahib at xtra dot co.nz
@ 2011-02-28  7:48 ` isahib at xtra dot co.nz
  2011-02-28  9:45 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: isahib at xtra dot co.nz @ 2011-02-28  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Ibaidul Sahib <isahib at xtra dot co.nz> 2011-02-28 06:53:23 UTC ---
(In reply to comment #1)
> do you think you could make the example more confusing? maybe if you named
> every namespace, class and member function the same, instead of only doing that
> for most of them? ;)

Abusive C++ :-) stripped from a real program but had mental problems
simplifying it further without losing the original context. Thanks for the
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47873#c5
sample.


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (8 preceding siblings ...)
  2011-02-28  7:48 ` isahib at xtra dot co.nz
@ 2011-02-28  9:45 ` redi at gcc dot gnu.org
  2011-02-28 23:25 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2011-02-28  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-28 09:31:32 UTC ---
(In reply to comment #8)
> Confirmed that this testcase runs fine with gcc 4.4.5/4.5.2
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47874 still fails on gcc
> 4.4.5/4.5.2

ah, I didn't realise it fails on different versions, sorry. I'll try to reduce
it and reopen Bug 47874


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (9 preceding siblings ...)
  2011-02-28  9:45 ` redi at gcc dot gnu.org
@ 2011-02-28 23:25 ` jason at gcc dot gnu.org
  2011-03-02 19:50 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2011-02-28 23:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2011-02-28 21:41:24 UTC ---
Author: jason
Date: Mon Feb 28 21:41:21 2011
New Revision: 170576

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170576
Log:
    PR c++/47873
    * class.c (update_vtable_entry_for_fn): Check BINFO_LOST_PRIMARY_P
    after checking for a non-thunk.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/covariant18.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (10 preceding siblings ...)
  2011-02-28 23:25 ` jason at gcc dot gnu.org
@ 2011-03-02 19:50 ` jason at gcc dot gnu.org
  2011-05-20  9:50 ` isahib at xtra dot co.nz
  2011-05-20 10:27 ` redi at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-02 19:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-02 19:49:50 UTC ---
Fixed.


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (11 preceding siblings ...)
  2011-03-02 19:50 ` jason at gcc dot gnu.org
@ 2011-05-20  9:50 ` isahib at xtra dot co.nz
  2011-05-20 10:27 ` redi at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: isahib at xtra dot co.nz @ 2011-05-20  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Ibaidul Sahib <isahib at xtra dot co.nz> 2011-05-20 09:29:00 UTC ---
(In reply to comment #12)
> Fixed.

Thanks I have tested this and the bug is fixed.

ggc-4.6 -v
==========
gcc version 4.6.1 20110329 (prerelease) (Debian 4.6.0-2) 

uname -a
========
Linux debian 2.6.38-2-amd64 #1 SMP Sun May 8 13:51:57 UTC 2011 x86_64 GNU/Linux

BTW who is responsible for changing the bug report Status to Verified/Closed,
QA or me?


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

* [Bug c++/47873] [4.6 Regression] virtual Inheritance - Covariant Virtual Function - Segfault
  2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
                   ` (12 preceding siblings ...)
  2011-05-20  9:50 ` isahib at xtra dot co.nz
@ 2011-05-20 10:27 ` redi at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-20 10:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-20 09:46:30 UTC ---
(In reply to comment #13)
> BTW who is responsible for changing the bug report Status to Verified/Closed,
> QA or me?

Don't bother, we don't use that status - RESOLVED+FIXED is all that's needed


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

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

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-24  7:13 [Bug c++/47873] New: Multiple Inheritance - Covariant Virtual Function - Segfault isahib at xtra dot co.nz
2011-02-25 10:50 ` [Bug c++/47873] " redi at gcc dot gnu.org
2011-02-25 11:18 ` redi at gcc dot gnu.org
2011-02-25 12:09 ` redi at gcc dot gnu.org
2011-02-25 12:35 ` [Bug c++/47873] [4.6 Regression] " redi at gcc dot gnu.org
2011-02-25 13:33 ` [Bug c++/47873] [4.6 Regression] virtual " redi at gcc dot gnu.org
2011-02-26 19:59 ` redi at gcc dot gnu.org
2011-02-27 19:31 ` jason at gcc dot gnu.org
2011-02-28  6:53 ` isahib at xtra dot co.nz
2011-02-28  7:48 ` isahib at xtra dot co.nz
2011-02-28  9:45 ` redi at gcc dot gnu.org
2011-02-28 23:25 ` jason at gcc dot gnu.org
2011-03-02 19:50 ` jason at gcc dot gnu.org
2011-05-20  9:50 ` isahib at xtra dot co.nz
2011-05-20 10:27 ` redi 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).