Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

g++: internal compiler error: Segmentation fault (program cc1plus) - where do I start?

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

like image 349
zabumba Avatar asked Jan 04 '23 23:01

zabumba


1 Answers

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
like image 81
zabumba Avatar answered Jan 06 '23 14:01

zabumba