public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66223] New: Diagnostic of pure virtual function call broken, including __cxa_pure_virtual
@ 2015-05-20 15:49 d.frey at gmx dot de
2015-05-21 9:08 ` [Bug c++/66223] " redi at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: d.frey at gmx dot de @ 2015-05-20 15:49 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/66223] Diagnostic of pure virtual function call broken, including __cxa_pure_virtual
2015-05-20 15:49 [Bug c++/66223] New: Diagnostic of pure virtual function call broken, including __cxa_pure_virtual d.frey at gmx dot de
@ 2015-05-21 9:08 ` redi at gcc dot gnu.org
2015-05-21 20:30 ` d.frey at gmx dot de
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2015-05-21 9:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66223
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I still get the same output for 5.1:
pure virtual method called
terminate called without an active exception
Aborted (core dumped)
How did you configure GCC? (Please provide the output of 'gcc -v`' as requested
in the bug reporting instructions)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/66223] Diagnostic of pure virtual function call broken, including __cxa_pure_virtual
2015-05-20 15:49 [Bug c++/66223] New: Diagnostic of pure virtual function call broken, including __cxa_pure_virtual d.frey at gmx dot de
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
3 siblings, 0 replies; 5+ messages in thread
From: d.frey at gmx dot de @ 2015-05-21 20:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66223
--- Comment #2 from Daniel Frey <d.frey at gmx dot de> ---
I'm using Ubuntu 14.04 in a VM, packages are installed from
http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main. Package
version is 5.1.0-0ubuntu11~14.04.1
Output from g++-5 -v:
Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.1.0-0ubuntu11~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=c++98 --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--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 5.1.0 (Ubuntu 5.1.0-0ubuntu11~14.04.1)
I'm compiling the example code with:
g++-5 -std=c++14 -O3 -Wall -Wextra t.cpp
I tried it without -O3 and it then prints the old output:
pure virtual method called
terminate called without an active exception
Aborted (core dumped)
So that probably means it has something to do with the optimizer?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/66223] [5/6 Regression] Diagnostic of pure virtual function call broken, including __cxa_pure_virtual
2015-05-20 15:49 [Bug c++/66223] New: Diagnostic of pure virtual function call broken, including __cxa_pure_virtual d.frey at gmx dot de
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 ` redi at gcc dot gnu.org
2015-10-16 8:27 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2015-05-22 9:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66223
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
Component|c++ |ipa
Summary|Diagnostic of pure virtual |[5/6 Regression] Diagnostic
|function call broken, |of pure virtual function
|including |call broken, including
|__cxa_pure_virtual |__cxa_pure_virtual
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
With -O2 you just get a segfault.
With -O1 or -O2 -fno-devirtualize you get the old output.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/66223] [5/6 Regression] Diagnostic of pure virtual function call broken, including __cxa_pure_virtual
2015-05-20 15:49 [Bug c++/66223] New: Diagnostic of pure virtual function call broken, including __cxa_pure_virtual d.frey at gmx dot de
` (2 preceding siblings ...)
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
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-16 8:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66223
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |5.3
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-16 8:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20 15:49 [Bug c++/66223] New: Diagnostic of pure virtual function call broken, including __cxa_pure_virtual d.frey at gmx dot de
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
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).