Bug 1177458
Summary: | cc1plus: internal compiler error: Segmentation fault | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 6 | Reporter: | Jason Pyeron <jpyeron> | ||||||
Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||||
Status: | CLOSED ERRATA | QA Contact: | Miroslav Franc <mfranc> | ||||||
Severity: | unspecified | Docs Contact: | |||||||
Priority: | unspecified | ||||||||
Version: | 6.7 | CC: | jpyeron, law, mcermak, mfranc, mpolacek, ohudlick | ||||||
Target Milestone: | rc | Keywords: | Reopened | ||||||
Target Release: | --- | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Whiteboard: | |||||||||
Fixed In Version: | gcc-4.4.7-12.el6 | Doc Type: | Bug Fix | ||||||
Doc Text: |
Previously, the compiler did not properly handle incorrect usage of the PCH (Precompiled Headers) feature. When a PCH file was not included as the first include, the compiler terminated unexpectedly with a segmentation fault. The compiler has been fixed not to use such an incorrect include, and it no longer crashes in this scenario.
|
Story Points: | --- | ||||||
Clone Of: | Environment: | ||||||||
Last Closed: | 2015-07-22 06:48:28 UTC | Type: | Bug | ||||||
Regression: | --- | Mount Type: | --- | ||||||
Documentation: | --- | CRM: | |||||||
Verified Versions: | Category: | --- | |||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||
Embargoed: | |||||||||
Attachments: |
|
Description
Jason Pyeron
2014-12-27 16:58:39 UTC
confirming that 4.9.2 compiled on RHEL6 does not crash on same source. You haven't attached the /tmp/ccYM4plV.out the compiler told you to attach (or whatever other file when you rerun it). Without that there is nothing we could do. Created attachment 977248 [details]
gcc tmp file
full source code available via git git clone https://github.com/CipherShed/CipherShed.git cd CipherShed git checkout 2154b9ff583610a5ab97821ed6b45646df2f4e2b cd src make Can't reproduce, works just fine with gcc-c++-4.4.7-11.el6.x86_64.rpm here. doing a fresh install, will make more detailed steps to reproduce. Created attachment 977470 [details] crash report from fresh install yum update -y && reboot yum install nano git gcc-c++ gcc make nasm kernel-devel fuse-devel wxGTK-devel -y git clone https://github.com/CipherShed/CipherShed.git cd CipherShed git checkout 2154b9ff583610a5ab97821ed6b45646df2f4e2b cd src make ... Compiling Main.cpp cc1plus: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/cc5F214H.out file, please attach this to your bugreport. make[1]: *** [Unix/Main.o] Error 1 make: *** [all] Error 2 Even that works for me fine. I am sorry, but I did not believe you last time, so I left out a step as a test. wxGTK-devel is not on RHEL6, you could not have completed that command on a fresh install. Would you like the VM image of the test system? I run what you've provided: /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1plus -quiet -mtune=generic -O2 -Wall -Wno-unused-parameter -fno-strict-aliasing -fdata-sections -ffunction-sections cc5F214H.out And that doesn't reproduce it. That is not the comamnd I provided. I do not know where you got that command. Below is the command in context, as in the attached file. [root@one-hundred-twenty-two-123 Main]# pwd /root/CipherShed/src/Main [root@one-hundred-twenty-two-123 Main]# /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1plus -quiet -I/root/CipherShed/src -I/root/CipherShed/src/Crypto -I/root/CipherShed/src/Main -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -MMD Unix/Main.d -MQ Unix/Main.o -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D TC_ARCH_X64 -DTC_UNIX -DTC_LINUX -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ Unix/Main.cpp -quiet -dumpbase Main.cpp -mtune=generic -auxbase-strip Unix/Main.o -O2 -Wall -Wno-unused-parameter -fno-strict-aliasing -fdata-sections -ffunction-sections -o - -frandom-seed=0 That is the same command, with the useless options filtered out. The file is already preprocessed, so there is no point for -I, -D options, -M* is also undesirable, -dumpbase/-auxbase-strip too, -o - too. Do you say that you can reproduce it with the #c12 command and not with #c11 command? Affirmative. /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1plus -quiet -mtune=generic -O2 -Wall -Wno-unused-parameter -fno-strict-aliasing -fdata-sections -ffunction-sections cc5F214H.out does not error. The problem appears to be in the preprocessor step: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64414#c1 For lazy sake: I added this yum repo for the 2nd test instead of rebuilding from tarball to get wx. rpm --import http://mirrors.kernel.org/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6 cat > /etc/yum.repos.d/extras.repo<<EOF [extras] name=CentOS-$releasever - Extras baseurl=http://mirror.centos.org/centos/6/extras/$basearch/ gpgcheck=1 EOF Then obviously the preprocessed source is not useful. Does it crash if you replace remove the -M* options from the command line (or just some of them)? Does it ICE if you replace -c with -E ? Can you remove some command line options and have it still crash? Can you remove some headers and have it still crash? For preprocessor ICE it is best to just create a minimal self-contained testcase and package the tree with all the necessary sources and headers needed to reproduce it. [root@one-hundred-twenty-two-123 tmp]# yum list | grep '@extras' bakefile.x86_64 0.2.8-3.el6.centos @extras python-empy.noarch 3.3-5.el6.centos @extras wxBase.x86_64 2.8.12-1.el6.centos @extras wxGTK.x86_64 2.8.12-1.el6.centos @extras wxGTK-devel.x86_64 2.8.12-1.el6.centos @extras wxGTK-gl.x86_64 2.8.12-1.el6.centos @extras wxGTK-media.x86_64 2.8.12-1.el6.centos @extras [root@one-hundred-twenty-two-123 tmp]# yum remove `cat` bakefile.x86_64 python-empy.noarch wxBase.x86_64 wxGTK.x86_64 wxGTK-devel.x86_64 wxGTK-gl.x86_64 wxGTK-media.x86_64 Loaded plugins: product-id, subscription-manager Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package bakefile.x86_64 0:0.2.8-3.el6.centos will be erased ---> Package python-empy.noarch 0:3.3-5.el6.centos will be erased ---> Package wxBase.x86_64 0:2.8.12-1.el6.centos will be erased ---> Package wxGTK.x86_64 0:2.8.12-1.el6.centos will be erased ---> Package wxGTK-devel.x86_64 0:2.8.12-1.el6.centos will be erased ---> Package wxGTK-gl.x86_64 0:2.8.12-1.el6.centos will be erased ---> Package wxGTK-media.x86_64 0:2.8.12-1.el6.centos will be erased --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================== Removing: bakefile x86_64 0.2.8-3.el6.centos @extras 1.1 M python-empy noarch 3.3-5.el6.centos @extras 497 k wxBase x86_64 2.8.12-1.el6.centos @extras 1.7 M wxGTK x86_64 2.8.12-1.el6.centos @extras 11 M wxGTK-devel x86_64 2.8.12-1.el6.centos @extras 4.3 M wxGTK-gl x86_64 2.8.12-1.el6.centos @extras 52 k wxGTK-media x86_64 2.8.12-1.el6.centos @extras 75 k Transaction Summary =============================================================================================================================================================================== Remove 7 Package(s) Installed size: 19 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : wxGTK-devel-2.8.12-1.el6.centos.x86_64 1/7 Erasing : wxGTK-gl-2.8.12-1.el6.centos.x86_64 2/7 Erasing : wxGTK-media-2.8.12-1.el6.centos.x86_64 3/7 Erasing : wxGTK-2.8.12-1.el6.centos.x86_64 4/7 Erasing : bakefile-0.2.8-3.el6.centos.x86_64 5/7 Erasing : python-empy-3.3-5.el6.centos.noarch 6/7 Erasing : wxBase-2.8.12-1.el6.centos.x86_64 7/7 Verifying : python-empy-3.3-5.el6.centos.noarch 1/7 Verifying : wxBase-2.8.12-1.el6.centos.x86_64 2/7 Verifying : wxGTK-gl-2.8.12-1.el6.centos.x86_64 3/7 Verifying : wxGTK-media-2.8.12-1.el6.centos.x86_64 4/7 Verifying : wxGTK-devel-2.8.12-1.el6.centos.x86_64 5/7 Verifying : bakefile-0.2.8-3.el6.centos.x86_64 6/7 Verifying : wxGTK-2.8.12-1.el6.centos.x86_64 7/7 Removed: bakefile.x86_64 0:0.2.8-3.el6.centos python-empy.noarch 0:3.3-5.el6.centos wxBase.x86_64 0:2.8.12-1.el6.centos wxGTK.x86_64 0:2.8.12-1.el6.centos wxGTK-devel.x86_64 0:2.8.12-1.el6.centos wxGTK-gl.x86_64 0:2.8.12-1.el6.centos wxGTK-media.x86_64 0:2.8.12-1.el6.centos Complete! [root@one-hundred-twenty-two-123 tmp]# pushd ~/CipherShed/src/Main /tmp [root@one-hundred-twenty-two-123 Main]# /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1plus -quiet -I/root/CipherShed/src -I/root/CipherShed/src/Crypto -I/root/CipherShed/src/Main -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -MMD Unix/Main.d -MQ Unix/Main.o -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D TC_ARCH_X64 -DTC_UNIX -DTC_LINUX -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ Unix/Main.cpp -quiet -dumpbase Main.cpp -mtune=generic -auxbase-strip Unix/Main.o -O2 -Wall -Wno-unused-parameter -fno-strict-aliasing -fdata-sections -ffunction-sections -o - -frandom-seed=0 .file "Main.cpp" cc1plus: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. [root@one-hundred-twenty-two-123 Main]# here is the workaround being used: [root@one-hundred-twenty-two-123 Main]# git show deaffa ... diff --git a/src/Main/Unix/Main.cpp b/src/Main/Unix/Main.cpp index eb64abb..30f2dfa 100644 --- a/src/Main/Unix/Main.cpp +++ b/src/Main/Unix/Main.cpp @@ -6,7 +6,7 @@ packages. */ -#include "System.h" +#include "../System.h" #include <sys/mman.h> #include "../../Platform/Platform.h" diff --git a/src/Main/Unix/System.h b/src/Main/Unix/System.h deleted file mode 100644 index d00fd16..0000000 --- a/src/Main/Unix/System.h +++ /dev/null @@ -1 +0,0 @@ -#include "../System.h" removal of -M* no effect. [root@one-hundred-twenty-two-123 Main]# /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1plus -quiet -I/root/CipherShed/src -I/root/CipherShed/src/Crypto -I/root/CipherShed/src/Main -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -MMD Unix/Main.d -MQ Unix/Main.o -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D TC_ARCH_X64 -DTC_UNIX -DTC_LINUX -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ Unix/Main.cpp -quiet -dumpbase Main.cpp -mtune=generic -auxbase-strip Unix/Main.o -O2 -Wall -Wno-unused-parameter -fno-strict-aliasing -fdata-sections -ffunction-sections -o - -frandom-seed=0 > /dev/null cc1plus: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. [root@one-hundred-twenty-two-123 Main]# /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1plus -quiet -I/root/CipherShed/src -I/root/CipherShed/src/Crypto -I/root/CipherShed/src/Main -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -MMD Unix/Main.d -MQ Unix/Main.o -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D TC_ARCH_X64 -DTC_UNIX -DTC_LINUX -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ Unix/Main.cpp -quiet -dumpbase Main.cpp -mtune=generic -auxbase-strip Unix/Main.o -O2 -Wall -Wno-unused-parameter -fno-strict-aliasing -fdata-sections -ffunction-sections -o - -frandom-seed=0 -E > /dev/null In file included from Unix/../System.h:14, from Unix/System.h:1, from Unix/Main.cpp:9: Unix/../SystemPrecompiled.h:10:19: warning: wx/wx.h: No such file or directory Unix/../SystemPrecompiled.h:11:25: warning: wx/filename.h: No such file or directory Unix/../SystemPrecompiled.h:12:24: warning: wx/mstream.h: No such file or directory Unix/../SystemPrecompiled.h:13:25: warning: wx/snglinst.h: No such file or directory Unix/../SystemPrecompiled.h:14:24: warning: wx/txtstrm.h: No such file or directory Unix/../SystemPrecompiled.h:15:25: warning: wx/wfstream.h: No such file or directory Unix/../SystemPrecompiled.h:18:20: warning: wx/dnd.h: No such file or directory Unix/../SystemPrecompiled.h:19:26: warning: wx/hyperlink.h: No such file or directory Unix/../SystemPrecompiled.h:20:25: warning: wx/listctrl.h: No such file or directory Unix/../SystemPrecompiled.h:21:25: warning: wx/imaglist.h: No such file or directory Unix/../SystemPrecompiled.h:22:22: warning: wx/power.h: No such file or directory Unix/../SystemPrecompiled.h:23:24: warning: wx/taskbar.h: No such file or directory Unix/../SystemPrecompiled.h:24:23: warning: wx/valgen.h: No such file or directory I have reproduced the bug: # rpm -q gcc gcc-4.4.7-11.el6.x86_64 # /usr/libexec/gcc/x86_64-redhat-linux/4.4.7/cc1plus -quiet -I/root/CipherShed/src -I/root/CipherShed/src/Crypto -I/root/CipherShed/src/Main -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D TC_ARCH_X64 -DTC_UNIX -DTC_LINUX -D__WXGTK__ Unix/Main.cpp -quiet -Occ1plus: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. #0 __strcmp_sse2 () at ../sysdeps/x86_64/strcmp.S:213 #1 0x0000000000af4c64 in splay_tree_splay (sp=0x141cf70, key=0) at ../../libiberty/splay-tree.c:148 #2 0x0000000000af4c89 in splay_tree_lookup (sp=0x141cf70, key=0) at ../../libiberty/splay-tree.c:389 #3 0x00000000006ae378 in get_fileinfo (name=0x0) at ../../gcc/c-lex.c:114 #4 0x00000000005a49af in start_preparsed_function (decl1=0x7ffff0630b00, attrs=0x0, flags=0) at ../../gcc/cp/decl.c:11562 #5 0x00000000005ba6f7 in start_function (declspecs=<value optimized out>, declarator=<value optimized out>, attrs=0x0) at ../../gcc/cp/decl.c:11961 #6 0x000000000062a86c in cp_parser_function_definition_from_specifiers_and_declarator ( parser=0x7ffff2044b90, decl_specifiers=0x7fffffffdd50, checks=0x0, function_definition_allowed_p=65 'A', member_p=0 '\000', declares_class_or_enum=<value optimized out>, function_definition_p=0x7fffffffddbf "\001\220K\004\362\377\177") at ../../gcc/cp/parser.c:17752 #7 cp_parser_init_declarator (parser=0x7ffff2044b90, decl_specifiers=0x7fffffffdd50, checks=0x0, function_definition_allowed_p=65 'A', member_p=0 '\000', declares_class_or_enum=<value optimized out>, function_definition_p=0x7fffffffddbf "\001\220K\004\362\377\177") at ../../gcc/cp/parser.c:12837 #8 0x00000000006129a2 in cp_parser_simple_declaration (parser=0x7ffff2044b90, function_definition_allowed_p=1 '\001') at ../../gcc/cp/parser.c:8259 #9 0x000000000062de4c in cp_parser_declaration (parser=0x7ffff2044b90) at ../../gcc/cp/parser.c:8062 #10 0x000000000062e9b5 in cp_parser_declaration_seq_opt (parser=0x7ffff2044b90) at ../../gcc/cp/parser.c:7953 #11 0x000000000062f1df in cp_parser_translation_unit () at ../../gcc/cp/parser.c:3046 #12 c_parse_file () at ../../gcc/cp/parser.c:22338 #13 0x00000000006afd1b in c_common_parse_file (set_yydebug=<value optimized out>) at ../../gcc/c-opts.c:1249 #14 0x000000000082d376 in compile_file (argc=<value optimized out>, argv=<value optimized out>) at ../../gcc/toplev.c:982 We find ourselves calling get_fileinfo with NULL. Trying to reduce it somehow... This happend when I added in the src/Main/Unix/System.h which was an include for ../System.h but beyond that I was unable to trouble shoot it. My workaround was to include ../System.h in each file explicitly. I think the following should reproduce the issue: $ mkdir -p t/a; cd t $ cat > x.h <<< '#include "xx.h"' $ cat > a/x.h <<< '#include "../x.h"' $ cat > a/m.C <<< '#include "x.h"' $ touch xx.h $ g++ xx.h -O -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D TC_ARCH_X64 -DTC_UNIX -DTC_LINUX -D__WXGTK__ $ g++ -c -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D TC_ARCH_X64 -DTC_UNIX -DTC_LINUX -D__WXGTK__ -O a/m.C cc1plus: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. less cruft, and a self validation. $ mkdir -p t/a; cd t $ cat > x.h <<< '#include "xx.h"' $ cat > a/x.h <<< '#include "../x.h"' $ cat > a/m.C <<< '#include "x.h"' $ cat >> a/m.C <<< 'int main(int argc, char** argv){return 0;}' $ g++ a/m.C $ ./a.out $ rm -f a.out $ g++ xx.h $ g++ -c a/m.C Note: # LD_LIBRARY_PATH=/root/mpc/lib/:/root/bin/gcc-4.9.2/lib/../lib64 \ /root/bin/gcc-4.9.2/bin/g++ xx.h # LD_LIBRARY_PATH=/root/mpc/lib/:/root/bin/gcc-4.9.2/lib/../lib64 \ /root/bin/gcc-4.9.2/bin/g++ -c a/m.C does not crash more random stuff: $ rm -f xx.h.gch m.o a.out $ cp xx.h.gch.4.9.2 xx.h.gch $ g++ -c a/m.C does not crash $ rm -f xx.h.gch m.o a.out $ cp xx.h.gch.4.4.7-11 xx.h.gch $ LD_LIBRARY_PATH=/root/mpc/lib/:/root/bin/gcc-4.9.2/lib/../lib64 \ /root/bin/gcc-4.9.2/bin/g++ -c a/m.C does not crash $ rm -f xx.h.gch m.o a.out $ cp xx.h.gch.4.4.7-11 xx.h.gch $ g++ -c a/m.C crashes. It's been fixed by 2009-09-22 Richard Guenther <rguenther> PR pch/38987 * files.c (pch_open_file): Disallow non-toplevel PCH inclusion. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151970 138bc75d-0d04-0410-961f-82ee72b054a4 which is --- a/libcpp/files.c +++ b/libcpp/files.c @@ -288,6 +288,12 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) if (file->name[0] == '\0' || !pfile->cb.valid_pch) return false; + /* If the file is not included as first include from either the toplevel + file or the command-line it is not a valid use of PCH. */ + if (pfile->all_files + && pfile->all_files->next_file) + return false; + flen = strlen (path); len = flen + sizeof (extension); pchname = XNEWVEC (char, len); The fix looks very safe. LGTM, but then we shouldn't backport just r151970, but also r185029. Fixed. QE: We don't have an internal test case for this, so you can use what's in Comment 22 and Comment 23. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2015-1339.html |