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

3

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

Vaticide answered 31/5, 2017 at 13:33 Comment(7)
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.Sarcenet
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.Martell
Report it here gcc.gnu.org/bugzilla 5.x is old though, you may want to install a newer version.Randers
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.Vaticide
@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.Vaticide
Try to find a GCC version 6 at least. Since GCC 7 has been recently released.Breeding
gist.github.com/application2000/…Randers
V
9

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
Vaticide answered 31/5, 2017 at 15:16 Comment(3)
I know it's old, but this fixed the issue for me too. CheersKufic
This answer really saved my dayTuraco
THANK YOU SO MUCH FOR THIS. I had an issue in WSL and I was trying to solve it for a while now with no hope, this fixed it for me! To be exact my issue was this: # github.com/mattn/go-sqlite3 during RTL pass: reload sqlite3-binding.c: In function ‘sqlite3Parser’: sqlite3-binding.c:173143:1: internal compiler error: Segmentation fault 173143 | } | ^ 0xd7a791 internal_error(char const*, ...) ???:0 0x11754f6 lra_constraints(bool) ???:0 0x116c72f lra(_IO_FILE*) ???:0Tyche
P
0

Simply do as you were instructed:

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

Pneumato answered 31/5, 2017 at 14:5 Comment(2)
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?Vaticide
The people who receive your bug report will be best placed to help you triage it and find a workaround.Pneumato
L
0

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
Leninism answered 17/11, 2022 at 1:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.