public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mitza at ociweb dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/55171] New: incorrect virtual thunk on mingw
Date: Thu, 01 Nov 2012 21:11:00 -0000	[thread overview]
Message-ID: <bug-55171-4@http.gcc.gnu.org/bugzilla/> (raw)


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

             Bug #: 55171
           Summary: incorrect virtual thunk on mingw
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mitza@ociweb.com


Created attachment 28593
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28593
test for virtual call on mingw

When a virtual call invoked on an object which uses both virtual and
non-virtual inheritance, the virtual thunk leaves the target function with an
invalid "this" pointer.

Attached test fails with output:

created Derived object at: 0x2c1a50
Derived virtual call at: 0x409800
Assertion failed!

>From gdb:
In the body of the most-derived constructor
(gdb) inf vt this
vtable for 'Derived' @ 0x4097ec (subobject @ 0x2c1a50):
[0]: 0x40188a <Derived::~Derived()>
[1]: 0x40190a <Derived::~Derived()>
[2]: 0x401932 <Derived::foo() const>

vtable for 'VirtBase' @ 0x409808 (subobject @ 0x2c1a58):
[0]: 0x401902 <virtual thunk to Derived::~Derived()>
[1]: 0x40192a <virtual thunk to Derived::~Derived()>
[2]: 0x4019d1 <virtual thunk to Derived::foo() const>

0x004019d1 in virtual thunk to Derived::foo() const () at gccbug.cpp:45
Dump of assembler code for function _ZTv0_n16_NK7Derived3fooEv:
=> 0x004019d1 <+0>:     mov    0x4(%esp),%eax
   0x004019d5 <+4>:     mov    (%eax),%eax
   0x004019d7 <+6>:     add    -0x10(%eax),%eax
   0x004019da <+9>:     mov    %eax,0x4(%esp)
   0x004019de <+13>:    jmp    0x401932 <Derived::foo() const>

After thunk has jumped to target function
Derived::foo (this=0x409800) at gccbug.cpp:41
41      {
(gdb) inf vt this
Cannot access memory at address 0xffffffec


             reply	other threads:[~2012-11-01 21:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-01 21:11 mitza at ociweb dot com [this message]
2012-11-02 11:13 ` [Bug c++/55171] " paolo.carlini at oracle dot com
2012-11-02 19:51 ` mitza at ociweb dot com
2012-11-02 20:13 ` [Bug target/55171] " paolo.carlini at oracle dot com
2012-11-07 21:10 ` mitza at ociweb dot com
2012-11-11 14:30 ` mikpe at it dot uu.se
2012-11-23 21:57 ` paolo.carlini at oracle dot com
2012-11-24 12:47 ` [Bug c++/55171] [4.7/4.8 Regression] " ktietz at gcc dot gnu.org
2012-11-24 12:54 ` ktietz at gcc dot gnu.org
2012-11-25 15:55 ` [Bug target/55171] " rguenth at gcc dot gnu.org
2012-11-29  9:19 ` ktietz at gcc dot gnu.org
2012-11-29  9:21 ` ktietz at gcc dot gnu.org
2012-11-29  9:25 ` ktietz at gcc dot gnu.org
2013-05-06  1:10 ` steve.k.chiu at gmail dot com
2013-05-06 22:31 ` i.nixman at gmail dot com

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-55171-4@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).