public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "d.frey at gmx dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66223] New: Diagnostic of pure virtual function call broken, including __cxa_pure_virtual Date: Wed, 20 May 2015 15:49:00 -0000 [thread overview] Message-ID: <bug-66223-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66223 Bug ID: 66223 Summary: Diagnostic of pure virtual function call broken, including __cxa_pure_virtual Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: d.frey at gmx dot de Target Milestone: --- Consider this small and certainly broken program: struct B { B* self; B() : self( this ) { self->f(); } virtual void f() = 0; }; struct D : B { void f() {} }; int main() { D d; } The ctor of B calls (indirectly) the pure virtual function f(), but the vtbl is still from B, not D (yet). Hence the program crashes. With GCC 4.9, I got: > ./a.out pure virtual method called terminate called without an active exception Aborted (core dumped) > Which is a good hint and I got a core dump. Fine so far. With GCC 5.1, I get this: > ./a.out Segmentation fault (core dumped) > Which is certainly less helpful. What is actually a lot worse is that even __cxa_pure_virtual is severly broken. I used to have my own __cxa_pure_virtual method to provide more output including a backtrace, something like this was my output for GCC 4.9: > ./a.out ### EMERGENCY ### pure virtual function called ### BACKTRACE ### build/release/test/emergency/pure_virtual_XFAIL(coin::core::output::backtrace()+0x23) [0x4034a3] build/release/test/emergency/pure_virtual_XFAIL(__cxa_pure_virtual+0x47) [0x4031f7] build/release/test/emergency/pure_virtual_XFAIL() [0x402a09] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7ff9dd52dec5] build/release/test/emergency/pure_virtual_XFAIL() [0x402b14] ### ABORTING ### Aborted (core dumped) > After the backtrace was printed to stdout, a core dump was written. With GCC 5.1, all I get is: > ./a.out > where at least the result code is not 0 (it's 128 if it helps). But no message and no core dump. Further experiments have shown that GCC 5.1 actually calls the terminate handler (which I also registered via std::set_terminate). This handler prints a backtrace and some other information when called on other errors, but for a pure virtual call it seems to be unable to even call a simple write() to stdout. Please let me know if you need further help to debug and fix this problem. I realize it's "just" a diagnostic in case of calling an unimplemented pure virtual method which should not be done in the first place, but I think the current situation is really hurting people when there is absolutely no message and no core dump and the process just returns with a non-zero exit code.
next reply other threads:[~2015-05-20 15:49 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-05-20 15:49 d.frey at gmx dot de [this message] 2015-05-21 9:08 ` [Bug c++/66223] " redi at gcc dot gnu.org 2015-05-21 20:30 ` d.frey at gmx dot de 2015-05-22 9:42 ` [Bug ipa/66223] [5/6 Regression] " redi at gcc dot gnu.org 2015-10-16 8:27 ` rguenth at gcc dot gnu.org
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-66223-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: linkBe 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).