# GCC segfault: could my cpu be overheating?

## [n00b@localhost]

Hi,

I am currently installing gentoo on my main desktop pc (athlon64x2 4800+, 2GB ram, 640GB raid array, nvidia geforce 7800gtx). I have already installed it on my laptop and got every bit of hardware working with it so decided, when I got a new pc, to put gentoo on it. I got through the installation guide ok and have a working 64bit system so far. I am trying to install kde but gcc keeps segfaulting at random points during the compile.

```
Options.cpp:501: internal compiler error: Segmentation fault

Please submit a full bug report,

with preprocessed source if appropriate.

See <URL:http://bugs.gentoo.org/> for instructions.

The bug is not reproducible, so it is likely a hardware or OS problem.

make[4]: *** [kstars.all_cpp.o] Error 1

make[4]: Leaving directory `/var/tmp/portage/kde-base/kstars-3.5.5/work/kstars-3.5.5/kstars/kstars'

make[3]: *** [all-recursive] Error 1

make[3]: Leaving directory `/var/tmp/portage/kde-base/kstars-3.5.5/work/kstars-3.5.5/kstars/kstars'

make[2]: *** [all-recursive] Error 1

make[2]: Leaving directory `/var/tmp/portage/kde-base/kstars-3.5.5/work/kstars-3.5.5/kstars'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/var/tmp/portage/kde-base/kstars-3.5.5/work/kstars-3.5.5'

make: *** [all] Error 2

!!! ERROR: kde-base/kstars-3.5.5 failed.

Call stack:

  ebuild.sh, line 1614:   Called dyn_compile

  ebuild.sh, line 971:   Called qa_call 'src_compile'

  environment, line 5003:   Called src_compile

  ebuild.sh, line 1304:   Called kde-meta_src_compile

  kde-meta.eclass, line 380:   Called kde_src_compile

  kde.eclass, line 170:   Called kde_src_compile 'all'

  kde.eclass, line 340:   Called kde_src_compile 'myconf' 'configure' 'make'

  kde.eclass, line 336:   Called die

!!! died running emake, kde_src_compile:make

!!! If you need support, post the topmost build error, and the call stack if relevant.

!!! A complete build log is located at '/var/log/portage/kde-base:kstars-3.5.5:20070330-231054.log'.

```

I have had a look around the forums and found the most probable causes of this are bad ram or an overheating cpu. I left memtest running on my pc while I went to work today and the memory checks out ok.

I have been using kde's system load monitor to monitor the temperature of my cpu when it's compiling but the temperatures it shows for each core are about 10 degrees lower than those reported in the bios when I start the pc. This uses the k8temp driver from lm_sensors so I also installed the it87(?) driver recommended by the sensors-detect script. This provides three more sensors: one diode and two thermistor (temp1, temp2 and temp3). In the console, temperatures (shown by running "sensors") increase to about 56, 41 and 39 degrees when compiling (for temp1, temp2 and temp3 respectfully). The temperatures shown by the k8temp driver remain about 10 degrees below this so I'm inclined to trust the it87 ones more. However, using the sensors provided by it87 in kde's system load monitor shows temp3 shooting up to 145 degrees(!!!) when compiling (temp1:28, temp2: 66)! Which sensors should I trust and which program should I use to read them (I'm currently doing "watch sensors" in another session when I compile)? What could be the cause of the random gcc segfaults? The cpu I have has a maximum safe working temperature of 72 degrees.

```

garyspc gary # cat /etc/make.conf

# These settings were set by the catalyst build script that automatically built this stage

# Please consult /etc/make.conf.example for a more detailed example

CHOST="x86_64-pc-linux-gnu"

CFLAGS="-O3 -march=athlon64 -fforce-addr -fomit-frame-pointer -ftracer -pipe"

CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"

ACCEPT_KEYWORDS="amd64"

PORTAGE_TMPDIR=/var/tmp

PORTDIR=/usr/portage

DISTDIR=${PORTDIR}/distfiles

PKGDIR=${PORTDIR}/packages

PORT_LOGDIR=/var/log/portage

PORTDIR_OVERLAY=/usr/local/portage

GENTOO_MIRRORS="ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/ http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/ ftp://mirrors.blueyonder.co.uk/mirrors/gentoo http://gentoo.blueyonder.co.uk/"

SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"

PORTAGE_RSYNC_RETRIES="3"

PORTAGE_RSYNC_EXTRA_OPTS="--timeout=180"

MAKEOPTS="-j3"

PORTAGE_NICENESS=15

AUTOCLEAN="yes"

FEATURES="candy ccache distlocks fixpackages parallel-fetch prelink sandbox userpriv usersandbox"

USE="3dnow a52 aac aalib accessibility acl acpi alsa amr apache2 ares arts avahi bash-completion bcmath bzip2 cddb dbus dga directfb dts dvd dxr3 encode exif fam fbcon fftw flac ftp gd ggi gif gnutls gphoto2 graphviz gs gstreamer hal idn ieee1394 imagemagick imap imlib jack java javascript jpeg kde kdeenablefinal kdexdeltas lcms libcaca lirc lm_sensors mad mmap mmx mng modplug mp3 mpeg mysql mysqli nis nptl nsplugin odbc ogg opengl php png posix qt3 qt4 rdesktop samba sasl scanner sdl slp sndfile sockets speex spell sse sse2 symlink theora threads tiff truetype unicode usb v4l vcd vorbis wifi wmf X x264 xcomposite xine xinerama xinetd xml xpm xsl xv xvid xvmc zeroconf"

CCACHE-SIZE="6G"

VIDEO_CARDS="nvidia"

INPUT_DEVICES="keyboard mouse"

LINGUAS="en"

LIRC_DEVICES=hauppauge_dvb

```

----------

## eccerr0r

Might want to check out http://www.gentoo.org/doc/en/articles/hardware-stability-p1.xml if you haven't already.

If you assembled it yourself, might want to check the heatsink to make sure it's firmly attached and not slightly on at an angle.

never trust the absolute values of the lm_sensors sensor values, only use relative values with values read from the same machine using the same software.  They are nowhere calibrated against each other...

----------

## [n00b@localhost]

Thanks for pointing me to that article. I didn't know it existed and it is really good. I worked out that kde's system monitor adds together all the sensors on one plot so my system wasn't at 145 degrees but that was the total from all three sensors around the cpu.   :Embarassed: 

 *eccerr0r wrote:*   

> never trust the absolute values of the lm_sensors sensor values, only use relative values with values read from the same machine using the same software. They are nowhere calibrated against each other...

 

Are you saying that I should trust the lm_sensors it87 temp1 values seeing as they most closely match those reported by the bios?

I ran memtest86 off the gentoo amd64 livecd for 14 and a half hours yesterday (22 passes) and it reported no errors so I think it's safe to say my ram is most probably fine.

I wrote my own version of the cpubuild script, ran it today and it crapped out with a segfault after 6 hours or so. The error I get is not the same as the one mentioned by the article (once I got a "Bus error", another time there was no error but X locked up but usually it is "The bug is not reproducible, so it is likely a hardware or OS problem."). During this time the maximum temperature reported by any of lm_sensors sensors was 57 degrees (I modified the script to keep track of the maximum temperature and kill the kernel compile if it got too hot   :Cool:  ). I'm at work so was a little late in noticing it had failed and by the time I tried to continue the compile the cpu had cooled to 45 degrees. It compiled fine when I continued it though. This would suggest my cooling is ok (I built the system myself) and that it is the cpu or another hardware fault.

I have noticed though that the segfaults occur mostly when gcc compiles c++ code. Today's segfault was the first I got when compiling c (the kernel is all straight c code yes?).

Could anything else such as an overheating chipset/dodgy hard drive/bad cflags cause gcc to segfault? How would I test this?

----------

## BitJam

Your problem is almost certainly caused overheating.

I also recently put Gentoo on an AMD x2 system (3600+).  The reason the it87 temps match those in the BIOS is because those are the only temps showing up in the BIOS.   The k8temp sensors are built into the AMD chip itself and are not associated with the BIOS.   In theory at least, the k8temp readings should be the ones you rely on since the sensors are actually inside the CPU.

I've posted a problem in a separate thread about getting unusually low temperature readings from k8temp.  When the computer first starts up the temperatures reported by k8temp were well under room temperature.  After a lot of Googling, ISTM that my problem was most likely an overall offset in the k8temp readings so I added the following lines to the k8temp section of /etc/sensors.conf:

```
   compute temp1 @+14,@-14

   compute temp3 @+14,@-14
```

One of the reasons I did this is that I read in one thread (somewhere) that the sensors in the AMD chips can have and offset of as much as +/- 14C.  Also there seemed to be general agreement that the sensors read correctly up to an overall offset.

On my board, ASUS m2npv-vm, even though the CPU heatsink is cool at idle, the northbridge runs very hot.  One of the it87 sensors seems to reflect this by registering temperatures much higher than k8temp even after the 14C adjustment I added.  My plan is to beef up the northbridge heatsink.

I too run a KDE desktop but I am totally addicted to using gkrellm to monitor my system.  It has very useful graphical displays of CPU usage, disk usage and net traffic in addition to all sensors outputs (but the sensor outputs are not graphical).   It uses some of the Gnome libraries but it is well worth installing.  I feel blind without it.   I also use it for showing me the local weather conditions, volume control and to show the phase of the moon.   The look is highly customizable.  Definitely install the gkrellm-themes package which will allow you to give it a look to fit in with your desktop.  I like the invisible themes.

One more thing,  have you enabled frequency scaling?  I'm using the 'ondemand' governor and it brings the temps way down when the comptuer is idling.  After making the 14C adjustment, my k8temp readings are now just a little above room temperature when the system is at idle.  This seems reasonable to me and agrees with what the CPU heatsink feels like when I touch it.

I'd love to see an official AMD document claiming the on-chip sensors are accurate once corrected for an overall offset but I haven't found such yet.

----------

## Tyrius

I had a similar problem when I replaced the motherboard/cpu of my desktop PC. When I was compiling glibc or gcc it would cause a segmentation fault. I ran memtests and cpu temp and couldn't get to the bottom of the issue. Eventually someone meantioned it could be that the new motherboard needed more power than the PSU could provide, and after replacing the PSU everything has compiled fine. Just another avenue of investigation you could have a look at.

----------

## krinn

You can try underclock your cpu to see if all works fine, underclocking will help it not getting too hot.

You can check MCE too, i think amd cpu could report thru mce a temp problem.

----------

## [n00b@localhost]

Thanks for all your replies.

This is the full spec of my PC:

ASUS M2N32-SLI Deluxe Wireless

2GB Crucial RAM

AMD Athlon X2 4800+

MSI nVidia Geforce 7800GTX Fanless

Creative X-Fi (I'm still waiting to get this working. Drivers from creative this quarter??)

Hauppauge WinTV Nova-T DVB

2x Samsung Spinpoint T 320GB hard drives

Sony DVD+-R/RW/RAM CD-R/RW

It is housed in one of these with one of these heatsinks (the nh-u9, the u12 is too big to fit in the case   :Shocked:  ). The way the components are arranged inside the case the cool air from the bottom gets blown straight into the cpu heatsink then blown over the graphics card and drawn out of the case by the psu fan. I have upgraded both the case fan and the psu fan to 70CFM/20dB models.

Although I have frequency scaling enabled I am not interested in underclocking or running my cpu any slower at this time (I'm compiling stuff - I want it done quick  :Cool:  ).

This is my sensors output (without altering sensors.conf):

```

it8716-isa-0290

Adapter: ISA adapter

VCore:     +1.38 V  (min =  +0.00 V, max =  +4.08 V)

VDDR:      +0.00 V  (min =  +0.00 V, max =  +4.08 V)   ALARM

+3.3V:     +3.34 V  (min =  +0.00 V, max =  +4.08 V)

+5V:       +4.92 V  (min =  +0.00 V, max =  +6.85 V)

+12V:     +12.03 V  (min =  +0.00 V, max = +16.32 V)

in5:       +3.70 V  (min =  +0.00 V, max =  +4.08 V)

in6:       +0.00 V  (min =  +0.00 V, max =  +4.08 V)   ALARM

5VSB:      +4.84 V  (min =  +0.00 V, max =  +6.85 V)

VBat:      +3.04 V

fan1:     1638 RPM  (min =    0 RPM)

fan2:        0 RPM  (min =    0 RPM)

fan3:        0 RPM  (min =    0 RPM)

temp1:       +47°C  (low  =    -1°C, high =  +127°C)   sensor = diode

temp2:       +35°C  (low  =    -1°C, high =  +127°C)   sensor = thermistor

temp3:       +38°C  (low  =    -1°C, high =  +127°C)   sensor = thermistor

vid:      +1.350 V

k8temp-pci-00c3

Adapter: PCI adapter

Core0 Temp:

             +38°C

Core0 Temp:

             +28°C

Core1 Temp:

             +24°C

Core1 Temp:

             +24°C

```

The fan speed matches up with the bios and the display on the front of the case. The BIOS is reporting temperatures of ~35C for the motherboard/northbridge and ~50C for the cpu (I just rebooted to find out. This is after recompiling the kernel successfully for 5 hours). Can someone tell me what temperature is what? Im assuming the k8temp sensors are the ones in the cpu and the it87 ones are on the motherboard. Why are there two readings for each core reported by k8temp? Why is core 1 10 degrees cooler than core 0? Where are the 3 sensors it87 is reporting?

If I add 14 to the temperatures for k8temp they seem much more reasonable btw, thanks BitJam!   :Wink: 

----------

