8

I am porting code that compiled on Ubuntu 14.04 to 16.04. I have cloned my git repo, installed dependencies and tried the usual make command, soon I hit a g++: internal compiler error: Segmentation fault (program cc1plus) ... yet I am not sure where to start to diagnose and resolve this issue.

I will share as much as I can, see if someone can guide me through a resolution.

Ubuntu

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial

g++

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

python

$ python --version
Python 2.7.12

Some environment variables

PYTHON       /usr/bin/python2.7
ARCH         x86_64
OS           Linux
VERSION      4.4.071generic
PLATFORM     linux2
HOSTNAME     deploy
USER         myUser
WUSS_BUILD   NO
CCVER        gcc
PYLIBDIR     build.x86_64-linux2
LIBDIR       build.x86_64-linux2
BINDIR       build.x86_64-linux2
ODIR         build.x86_64-linux2-gcc
STATICLIBDIR build-static.x86_64-linux2

Error

The make command leads to

+++ Compile mycore/boost_json.cc to build.x86_64-linux2-gcc
g++: internal compiler error: Segmentation fault (program cc1plus)   <===
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
mk/makelib2.inc:48: recipe for target 'build.x86_64-linux2-gcc/mycore/boost_json.o' failed
make[1]: *** [build.x86_64-linux2-gcc/mycore/boost_json.o] Error 4
Makefile:152: recipe for target 'make.stage1c' failed
make: *** [make.stage1c] Error 2

The error message seems to be pointing at a g++ compiler error (?)

makelib2.inc:48

$(ODIR)/%.o : %.c
        @mkdir -p $(dir $@)
        @echo "+++ Compile $< to $(ODIR)"
        @$(CC) -MMD -MP -MF $(@:.o=.d) -c -I$(ODIR) $(CFLAGS) $(CFLAGS_$*) -o $@ $<

I realize that this is going to be very difficult to craft a proper question that would lead to getting proper help. So please bear with me and feel free to suggest adding anything that may help. Unfortunately, I can't share the code.

Update

Going to try upgrade g++ to a more recent version. Following this thread

HERE how to install g++ 7 on Ubuntu

HERE how to install gcc 6 on Ubuntu

zabumba
  • 12,172
  • 16
  • 72
  • 129
  • We probably need to see what command-line was generated for `@$(CC) -MMD -MP -MF $(@:.o=.d) -c -I$(ODIR) $(CFLAGS) $(CFLAGS_$*) -o $@ $<` when compiling the boost_json.o target. – Paul R May 31 '17 at 13:37
  • 6
    Like the error message say, you should file a bug report to gcc (if there is not already one for the same bug). Internal compiler error are always bug in the compiler. – nefas May 31 '17 at 13:38
  • 1
    Report it here https://gcc.gnu.org/bugzilla 5.x is old though, you may want to install a newer version. – n. m. could be an AI May 31 '17 at 14:06
  • ha! I figured I was working with latest. on my Ubuntu 14.04 I was working with `g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4`. – zabumba May 31 '17 at 14:46
  • @n.m. do you know the right way to upgrade `g++` to its latest version. I think your suggestion may resolve my issue, please feel free to add it as answer. – zabumba May 31 '17 at 14:57
  • 1
    Try to find a GCC version 6 at least. Since GCC 7 has been recently released. – Basile Starynkevitch May 31 '17 at 14:58
  • https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91 – n. m. could be an AI May 31 '17 at 15:47

3 Answers3

8

How I resolved my g++ segmentation fault issue

Inspired by this thread

I executed the following on my Ubuntu 16.04

   sudo apt-get install build-essential software-properties-common -y
   sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y 
   sudo apt-get update
   sudo apt-get install gcc-snapshot -y 

After what g++ was incremented from 5.4.0 to 5.4.1 which resolve the segmentation fault issue

$ g++ --version
g++ (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
zabumba
  • 12,172
  • 16
  • 72
  • 129
1

If you can't solve your problem using above methods, you can have a try to check if you are running out of disk space using below command. This is the workaround of my problem.

df -h
sudo du -h --max-depth=1
WangYang
  • 466
  • 1
  • 5
  • 15
-1

Simply do as you were instructed:

Please submit a full bug report, with preprocessed source if appropriate.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • right, I guess that's one thing, although that doesn't resolve my issue. What might resolve is installing (as suggested in the comments) a more recent version of the `g++` on Ubuntu 16.04 if that's supported, because this issue may have been resolved already right? – zabumba May 31 '17 at 14:48
  • 2
    The people who receive your bug report will be best placed to help you triage it and find a workaround. – Lightness Races in Orbit May 31 '17 at 15:01