gcc segmentation fault on Ubuntu 12.04
This segmentation fault really should not happen. I suspect something is wrong with the binaries installed on your system - possibly because of the symbolic link you created.
Try reinstalling GCC and all affecting libraries:
sudo apt-get install --reinstall gcc gcc-4.6 gcc-4.6-base libgcc1 cpp-4.6
Specifically the cpp-4.6 package appears to be broken in your setup as /usr/lib/gcc/x86_64-linux-gnu/4.6/cc1
belongs to that package and the error output you've provided indicates the cause of the issue is in there somewhere.
Related videos on Youtube
Yuval F
I am a software developer. I like search engines, machine learning and natural language processing. Currently working on something new.
Updated on September 18, 2022Comments
-
Yuval F over 1 year
I am trying to compile a C program on Ubuntu precise 12.04. Here's the program:
#include <stdio.h> int main(int argc, char** argv) { printf("Hello World!"); return 0; }
My gcc version is 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5). Initially it did not find cc1 so I added a soft link. Now I get this message when I try to compile:
gcc: internal compiler error: Segmentation fault (program cc1)
Compiling the same program with g++ works fine.
I tried reinstalling build-essential, but to no avail. What am I missing?
EDIT: I tried reinstalling according to @gertyvdijk's suggestion. As it did not help, here is the output of
apt-cache policy gcc-4.6
:gcc-4.6: Installed: 4.6.3-1ubuntu5 Candidate: 4.6.3-1ubuntu5 Version table: *** 4.6.3-1ubuntu5 0 500 http://il.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages 100 /var/lib/dpkg/status
and the output of
ls -l /usr/bin/gcc
:lrwxrwxrwx 1 root root 7 Mar 13 2012 /usr/bin/gcc -> gcc-4.6
EDIT #2: here's a verbose compiler output:
gcc -v aaa.c Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --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 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.6/cc1 -quiet -v -imultilib . -imultiarch x86_64-linux-gnu aaa.c -quiet -dumpbase aaa.c -mtune=generic -march=x86-64 -auxbase aaa -version -fstack-protector -o /tmp/ccHfcXMs.s gcc: internal compiler error: Segmentation fault (program cc1) Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
-
green almost 11 yearsTry
cc <filename.c>
. -
gertvdijk almost 11 years"I tried reinstalling build-essential" - That's just a metapackage. You'll have to reinstall the plain GCC packages to properly reinstall all
gcc
binaries. Tryapt-get reinstall gcc gcc-4.6 gcc-4.6-base libgcc1
. If that does not work, please also provide the output ofapt-cache policy gcc-4.6
andls -l /usr/bin/gcc
in your question. -
Yuval F almost 11 yearsDid not work. Please see the updated question.
-
gertvdijk almost 11 yearsGCC package installation looks all good. I am unable to reproduce this using the exact same gcc version and the source you provided - binary returns "Hello World!" as expected. It could be that a Bash alias in your user profile is the culprit. Could you try to invoke gcc using this more explicit command?
/usr/bin/gcc sourcefile.c -o helloworld
. Oh and I meantsudo apt-get install --reinstall gcc gcc-4.6 gcc-4.6-base libgcc1
in my previous comment. (there's no such action asapt-get reinstall
.) -
Yuval F almost 11 yearsThanks Gert, but the full path gives the same result. I have added a verbose compiler output - maybe you will be able to see something off there.
-
gertvdijk almost 11 yearsRe-reading "Initially it did not find cc1 so I added a soft link." <-- What exactly did you do and why? I now think you mean
/usr/lib/gcc/x86_64-linux-gnu/4.6/cc1
from thecpp-4.6
package - was it absent? It should just be there - it's a hard dependency of gcc. Try reverting the symbolic link you created and reinstall that package. -
Yuval F almost 11 yearsThat did the trick, thanks. Please build an answer from your comments, so I can upvote and accept it.
-
-
Amadu Bah almost 10 yearsThe version need to be the same as the installed cc1. In my case was 4.8 "/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1". So the command
sudo apt-get install --reinstall gcc gcc-4.8 gcc-4.8-base libgcc1 cpp-4.8
did the trick -
Nathan B over 6 yearsStill getting the 'segmentation fault'
-
Geoff over 6 yearsThanks, the following worked for me:
sudo apt-get install --reinstall gcc gcc-4.9 gcc-4.9-base libgcc1 cpp-4.9
Note: this is actually on Raspian Jessy.