This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64830] New: g++ generating segfaulting binaries
- From: "amigo.elite at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 28 Jan 2015 11:05:09 +0000
- Subject: [Bug c++/64830] New: g++ generating segfaulting binaries
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64830
Bug ID: 64830
Summary: g++ generating segfaulting binaries
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: amigo.elite at gmail dot com
Created attachment 34601
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34601&action=edit
Test case sources (.proto, .cc) and temporary .ii
Starting from 4.6 (perhaps, I can't test every version) g++ generating binaries
that was segfaulting.
Test case was attached.
How to reproduce:
First of all, you will need a protobuf compiler (named protoc) and protobuf
headers installed on test system.
I'm sorry, but escaping from protobuf dependencies to write a self sufficient
test case requires a lot of work but this dependency should not be a problem
(at least I hope so).
1. Create a new directory with source files that was attached and cd into it
2. Run protoc testcase.proto --cpp_out=./
3. Run g++ -g -lprotobuf -lstdc++ -o testcase *cc
4. Run ./testcase
Actual result:
Segfault because of NULL dereference in protobuf.
Expected result:
Protobuf class members should be initialized properly (that's not a protobuf
bug, please read details).
Additional information:
I have done some additional tests and according to results segfault occurs only
when g++ version is greater then 4.5.1.
You can see detailed list of systems here:
https://github.com/Am1GO/gcc-testcase/blob/master/README.md
If you dislike external links, here is the list of systems which I've done
testing on:
Failed (segfault occurs):
Fedora 15 x86_64 (gcc 4.6.3)
Debian stable 7.8 x86_64 (gcc 4.7.2)
Fedora 20 x86_64 (gcc 4.8.3)
Fedora 21 x86_64 (gcc 4.9.2)
Debian unstable i586 (gcc 4.9.2)
Works fine (no segfault):
Ubuntu 10.04.3 LTS x86_64 (gcc 4.4.3)
Fedora 13 x86_64 (gcc 4.4.5)
Scientific Linux 6.6 i686 (gcc 4.4.7)
Fedora 14 x86_64 (gcc 4.5.1)
FreeBSD 10.1-RELEASE amd64 (clang 3.3)
FreeBSD 10.1-RELEASE amd64 (clang 3.4.2)
FreeBSD 10.1-RELEASE amd64 (clang 3.5.0)
Why do I think that it's not a protobuf bug?
Because I've taken protobuf packages from EPEL6 (protobuf 2.3) and installed
them to Fedora 20 which provides protobuf 2.5 and vice versa (i.e. protobuf 2.5
from Fedora installed on Scientific 6.6).
Segfault occurs on Fedora (gcc 4.8.3) with protobuf 2.3 and 2.5.
No segfault occurs on Scientific 6.6 (gcc 4.4.7) with protobuf 2.3 or 2.5.
Compiling with -fno-strict-aliasing -fwrapv makes no difference (Fedora 20
x86_64 with gcc 4.8.3).
There is some workaround available (I've tested it only on Fedora 20 x86_64
with gcc 4.8.3): compiling with -O1 or greater optimization enabled makes g++
to produce valid executable (no segfault occurs).
According to your summarized bug reporting instructions I need to include some
additional information so here it is:
the exact version of GCC: 4.8.3 20140911 (Red Hat 4.8.3-7)
the system type: x86_64-redhat-linux, Fedora release 20 (Heisenbug) with
all updates
the options given when GCC was configured/built: --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap
--enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-isl=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-redhat-linux/cloog-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
the complete command line that triggers the bug: g++ -g -lprotobuf -lstdc++
-o testcase *cc
the compiler output (error messages, warnings, etc.): no messages except
unused argc and argv in main()
the preprocessed file (*.i*) that triggers the bug, generated by adding
-save-temps to the complete compilation command, or, in the case of a bug
report for the GNAT front end, a complete set of source files: attached