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

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

我正在将在 Ubuntu 14.04 上编译的代码移植到 16.04。我已经克隆了我的 git 存储库,安装了依赖项并尝试了通常的 make 命令,很快我就遇到了 g++: internal compiler error: Segmentation fault (program cc1plus) ...但是我不确定从哪里开始诊断和解决这个问题.

我会尽可能多地分享,看看是否有人可以指导我解决问题。

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

一些环境变量

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

错误

make命令导致

+++ 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

错误消息似乎指向 g++ 编译器错误 (?)

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 $@ $<

我意识到要设计一个能够获得适当帮助的适当问题将非常困难。所以请耐心等待,并随时建议添加任何可能有帮助的内容。不幸的是,我不能分享代码。

更新

将尝试升级 g++ 到更新的版本。正在关注 this thread

HERE how to install g++ 7 on Ubuntu

HERE how to install gcc 6 on Ubuntu

按照指示进行即可:

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

我如何解决 g++ 分段错误问题

灵感来自 this thread

我在 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 

g++5.4.0 增加到 5.4.1 之后解决了分段错误问题

$ g++ --version
g++ (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904