This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/5270: MI + virtual base: segfault when throwing an exception in a derived ctor



>Number:         5270
>Category:       c++
>Synopsis:       MI + virtual base: segfault when throwing an exception in a derived ctor
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 03 18:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Daniel Elstner
>Release:        gcc version 3.0.4 20020103 (prerelease)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
Scenario:  A particular inheritance construct involving MI and one virtual base class (for further details please look at the test case).  When the ctor of the most-derived class throws an exception, the program receives a SIGSEGV.

The problem seems to occur only if both base classes, the virtual and the non-virtual one, have a virtual dtor.  I was also able to reproduce (the closed) PR #2276, which seems to be the same issue.

The segfault is reproduceable with gcc releases 3.0.2, 3.0.3, and CVS 3.0.4 20020103.  It works fine with 2.95.4 20010319 and RedHat's 2.96 (don't know the exact revision).
>How-To-Repeat:
g++ -o test-ctor-throw test-ctor-throw.cc
./test-ctor-throw

It should print "exception caught: foobar" if it works.  Using the gcc versions mentioned in the PR description, it receives a segmentation fault.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test-ctor-throw.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test-ctor-throw.cc"

CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxzdGRleGNlcHQ+CgoKc3RydWN0IEEKewogIEEo
KSAgICAgICAgICB7IHB1dHMoX19QUkVUVFlfRlVOQ1RJT05fXyk7IH0KICB2aXJ0dWFsIH5BKCkg
eyBwdXRzKF9fUFJFVFRZX0ZVTkNUSU9OX18pOyB9Cn07CgpzdHJ1Y3QgQgp7CiAgQigpICAgICAg
ICAgIHsgcHV0cyhfX1BSRVRUWV9GVU5DVElPTl9fKTsgfQogIHZpcnR1YWwgfkIoKSB7IHB1dHMo
X19QUkVUVFlfRlVOQ1RJT05fXyk7IH0KfTsKCnN0cnVjdCBDIDogdmlydHVhbCBwdWJsaWMgQSwg
cHVibGljIEIKewogIEMoKSAgICAgICAgICB7IHB1dHMoX19QUkVUVFlfRlVOQ1RJT05fXyk7IH0K
ICB2aXJ0dWFsIH5DKCkgeyBwdXRzKF9fUFJFVFRZX0ZVTkNUSU9OX18pOyB9Cn07CgpzdHJ1Y3Qg
RCA6IHB1YmxpYyBDCnsKICBEKCkgewogICAgcHV0cyhfX1BSRVRUWV9GVU5DVElPTl9fKTsKICAg
IHRocm93IHN0ZDo6cnVudGltZV9lcnJvcigiZm9vYmFyIik7CiAgfQogIHZpcnR1YWwgfkQoKSB7
IHB1dHMoX19QUkVUVFlfRlVOQ1RJT05fXyk7IH0KfTsKCgppbnQgbWFpbihpbnQgYXJnYywgY2hh
cioqIGFyZ3YpCnsKICB0cnkKICB7CiAgICBEIGQ7CiAgfQogIGNhdGNoKGNvbnN0IHN0ZDo6ZXhj
ZXB0aW9uJiBlKQogIHsKICAgIHByaW50ZigiZXhjZXB0aW9uIGNhdWdodDogJXNcbiIsIGUud2hh
dCgpKTsKICB9CgogIHJldHVybiAwOwp9Cgo=


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]