I installed ubuntu server 10.04 and booted as normal.

Some time later, I booted the server and tried to install a new package/upgrade the existing packages using:

sudo apt-get upgrade
sudo aptitude safe-upgrade
sudo apt-get install ntp
Reading package lists... Done
Segmentation faulty tree... 50%

I checked the system log /var/log/messages and found these entries:

kernel: [ 5586.184028] apt-get[3864]: segfault at 7fb5e078477b ip 00007fb5da82223c sp 00007fffa943b430 error 6 in libapt-pkg-libc6.10-6.so.4.8.0[7fb5da7e1000+c5000]
kernel: [ 5682.494467] aptitude[3973]: segfault at 7f06d4c4d77b ip 00007f06d063723c sp 00007fff5feb8540 error 6 in libapt-pkg-libc6.10-6.so.4.8.0[7f06d05f6000+c5000]
kernel: [ 5991.238428] apt-get[4181]: segfault at 7f809c17e77b ip 00007f809621c23c sp 00007fff740deb30 error 6 in libapt-pkg-libc6.10-6.so.4.8.0[7f80961db000+c5000]

Also, I got the same error while trying to use aptitude safe-upgrade as it is clear from the log file.

How can this be fixed without system re-installation?


Solution 1:

Firstly, try this command (from terminal) as root:

rm -rf /var/cache/apt/*.bin

And try apt-get upgrade again. If the problem still persist, you probably found a bug. Go to launchpad bug and report your problem. Remember to include details like Ubuntu server version or any other relevant information.

Thanks!

Solution 2:

First I tried

rm -rf /var/cache/apt/*.bin

as mentioned above.

Then I was still getting crashes when I was trying to install/remove something. Either with apt-get or with aptitude.

It was always a segfault in libapt-pkg-libc6.10-6.so.4.8.0.

It turned out that one memory module was corrupt (checked it using memtest86).

After fixing that, I still was getting the same segfaults, so:

  1. Fetched the apt_0.7.25.3ubuntu9.7_i386.deb in /tmp

  2. Extract

    cd /tmp
    ar xv apt_0.7.25.3ubuntu9.7_i386.deb 
    
  3. Moved the correct file to the correct place

    cd /tmp/usr/lib
    mv -vi libapt-pkg-libc6.10-6.so.4.8* /usr/lib/
    

all right now.