# segfault while emerging gcc

## Nicias

Hello, during a recent upgrade of gcc I saw this in dmesg:

```
[3104318.666731] cc1plus[31132]: segfault at 30c3cb76500 ip 00000000011226a1 sp 000003a391dfd1e0 error 4 in cc1plus[400000+1198000]

[3104385.153745] cc1plus[7584]: segfault at 324988b2600 ip 00000000011226a1 sp 000003ef776ef520 error 4 in cc1plus[400000+1198000]

```

However, emerge doesn't complain. In fact it doesn't seem to mind. Is this a problem?

 I'm currently rebuilding the toolchain to see if that stops it.

emerge --info

```
Portage 2.2.7 (hardened/linux/amd64, gcc-4.7.3, glibc-2.17, 3.11.7-hardened-r1 x86_64)

=================================================================

System uname: Linux-3.11.7-hardened-r1-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T5270_@_1.40GHz-with-gentoo-2.2

KiB Mem:     2039492 total,    218116 free

KiB Swap:    2097148 total,   2078628 free

Timestamp of tree: Sun, 02 Feb 2014 08:00:01 +0000

ld GNU ld (GNU Binutils) 2.23.2

app-shells/bash:          4.2_p45

dev-lang/python:          2.7.5-r3, 3.2.5-r3, 3.3.3

dev-util/cmake:           2.8.11.2

dev-util/pkgconfig:       0.28

sys-apps/baselayout:      2.2

sys-apps/openrc:          0.12.4

sys-apps/sandbox:         2.6-r1

sys-devel/autoconf:       2.13, 2.69

sys-devel/automake:       1.11.6, 1.13.4

sys-devel/binutils:       2.23.2

sys-devel/gcc:            4.7.3-r1

sys-devel/gcc-config:     1.7.3

sys-devel/libtool:        2.4.2

sys-devel/make:           3.82-r4

sys-kernel/linux-headers: 3.9 (virtual/os-headers)

sys-libs/glibc:           2.17

Repositories: gentoo robbins_local

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="* -@EULA"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-O2 -pipe -march=native -fomit-frame-pointer"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-O2 -pipe -march=native -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FCFLAGS="-O2 -pipe"

FEATURES="assume-digests binpkg-logs collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"

FFLAGS="-O2 -pipe"

GENTOO_MIRRORS="http://gentoo.cites.uiuc.edu/pub/gentoo/ http://www.gtlib.gatech.edu/pub/gentoo http://mirrors.rit.edu/gentoo/"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/var/portage"

PORTDIR_OVERLAY="/var/local-portage"

USE="acl amd64 berkdb bzip2 cli consolekit cpudetection cracklib crypt cxx dri dts dvd faac gdbm gudev hardened hwdb iconv ipv6 justify matroska mmx mmxext modules mp3 mp4 multilib ncurses nls nptl openmp pam pax_kernel pcre pic policykit python readline session sse sse2 ssl ssse3 tcpd threads unicode urandom x264 xml xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby20" USERLAND="GNU" VIDEO_CARDS="intel vesa fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SYNC, USE_PYTHON
```

make.conf

```
# These settings were set by the catalyst build script that automatically

# built this stage.

# Please consult /usr/share/portage/config/make.conf.example for a more

# detailed example.

CFLAGS="-O2 -pipe -march=native -fomit-frame-pointer"

CXXFLAGS="${CFLAGS}"

# WARNING: Changing your CHOST is not something that should be done lightly.

# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.

CHOST="x86_64-pc-linux-gnu"

MAKEOPTS="-j3"

FEATURES="collision-protect parallel-fetch sandbox -metadata-transfer splitdebug"

USE="mmx mmxext sse sse2 ssse3 -X xml -cups unicode policykit consolekit\

        -opengl  -osdmenu -xscreensaver -xv pic  python -iptables\

        gudev hwdb -gnome\

        xvid mp3 x264 faac mp4 dts matroska dvd threads cpudetection"

VIDEO_CARDS="intel vesa fbdev"

INPUT_DEVICES="keyboard mouse evdev synaptics"

RUBY_TARGETS="ruby20"

LINGUAS="en"

PORTDIR="/var/portage"

PORTDIR_OVERLAY="/var/local-portage/"

GENTOO_MIRRORS="http://gentoo.cites.uiuc.edu/pub/gentoo/ http://www.gtlib.gatech.edu/pub/gentoo http://mirrors.rit.edu/gentoo/"

#SYNC="rsync://rsync3.us.gentoo.org/gentoo-portage"
```

----------

## Pearlseattle

Hi

It depends - it might - probably it does?  :Wink: 

I became aware of such a problem 2 weeks ago while upgrading an old PC (which has some AMD <something> black edition CPU).

Saw such an error message while compiling gcc 4.7, then ran other tests with some other big packages (e.g. glibc) and got from time to time segfaults - some of them made the compilation stop, others didn't.

Identified the problem (overheating) by lowering the max CPU clock in "/sys/devices/system/cpu/cpu[ALL]/cpufreq/scaling_max_freq" and recompiling without "almost" getting such weird messages (if I remember correctly glibc always outputted one, no matter what), which means that in my case the CPU was getting unreliable when going above ~60C (I always had problems with AMD CPUs & GPUs...).

Fastest way for you to check if you're affected by something similar is to recompile gcc after setting your CPU freq to powersave/min. freq. .

Cheers

----------

## Anon-E-moose

More than likely some type of hardware problem

Could be memory or the power supply being flaky, pushing the cpu/memory will take more juice.

----------

## Nicias

I don't think it is. I recompiled with a lowered clock speed. Same errors. I compiled glibc with a high clock speed. No errors. I compiled gcc with the full speed clock. Same errors, at the same locations in both the compile process (afaict by clock time) and the executable.

```
Feb 11 18:01:55 [kernel] [3814989.405000] cc1plus[28793]: segfault at 32ea03a59b8 ip 00000000011226a1 sp 000003aef29fbf60 error 4 in cc1plus[400000+1198000]

Feb 11 18:03:52 [kernel] [3815106.078697] cc1plus[5268]: segfault at 34498d4c678 ip 00000000011226a1 sp 000003982efff760 error 4 in cc1plus[400000+1198000]

Feb 11 19:10:05 [kernel] [3819079.115525] cc1plus[20994]: segfault at 32b7a82ff6c ip 0000000000d8bf69 sp 000003df45dc97d0 error 4 in cc1plus[400000+d63000]

Feb 11 19:11:32 [kernel] [3819166.591543] cc1plus[29289]: segfault at 2ec168830b4 ip 0000000000d8bf69 sp 000003a2dfe22910 error 4 in cc1plus[400000+d63000]

Feb 11 19:45:12 [kernel] [3821186.076631] cc1plus[12693]: segfault at 2a0d81b6f64 ip 0000000000d8bf69 sp 000003d38eb82390 error 4 in cc1plus[400000+d63000]

Feb 11 19:46:40 [kernel] [3821274.615069] cc1plus[21032]: segfault at 3745ee13f2c ip 0000000000d8bf69 sp 0000039c7e3d4950 error 4 in cc1plus[400000+d63000]

```

then with full speed cpu:

```

Feb 12 06:34:47 [kernel] [3860161.418951] cc1plus[32732]: segfault at 3644271e150 ip 00000000011226a1 sp 000003b9f9768a60 error 4 in cc1plus[400000+1198000]

Feb 12 06:35:53 [kernel] [3860227.507267] cc1plus[9017]: segfault at 316114e9d00 ip 00000000011226a1 sp 00000395f02ba120 error 4 in cc1plus[400000+1198000]

Feb 12 07:13:51 [kernel] [3862505.864425] cc1plus[24686]: segfault at 2acde7d5844 ip 0000000000d8bf69 sp 000003eb51960dd0 error 4 in cc1plus[400000+d63000]

Feb 12 07:14:41 [kernel] [3862555.596701] cc1plus[639]: segfault at 301ab03bb9c ip 0000000000d8bf69 sp 000003ce1fc05cd0 error 4 in cc1plus[400000+d63000]

Feb 12 07:34:04 [kernel] [3863718.318532] cc1plus[16391]: segfault at 2ed30d1980c ip 0000000000d8bf69 sp 0000039979d24650 error 4 in cc1plus[400000+d63000]

Feb 12 07:34:53 [kernel] [3863767.220697] cc1plus[24582]: segfault at 344bbce88cc ip 0000000000d8bf69 sp 000003f896cd84d0 error 4 in cc1plus[400000+d63000]

```

Two pairs of segaults, at the same locations in the executable, with the same instruction pointers. Seems to reproducible to be a hardware failure.

----------

## flinx

In my case immediately after upgrading glibc to =sys-libs/glibc-2.17 I'd encountered  massive segfaults in many applications even last stage of glibc upgrading failed.

So i have to downgrade glibc from =sys-libs/glibc-2.17 to =sys-libs/glibc-2.15-r3

----------

