14.04 LTS apt-get segfault

Trying to update my web server, apt-get update produces this unhelpful error after reaching 99% while reading package lists at the end:

...
Ign http://mirror.rackspace.com trusty/universe Translation-en_US           
Reading package lists... Error!

If I attempt to install any software or run apt-get upgrade it merely prints ... 0% and fails silently.

In dmesg, I see this worrisome line appearing with each attempt to update or upgrade:

[481989.865258] apt-get[17869]: segfault at ffffffffffffffff ip 00007f56e468fccb sp 00007fff4c83df10 error 5 in libapt-pkg.so.4.12.0[7f56e4639000+145000]

I'm not sure where to go from here!

EDIT: This appears to be a resources/memory issue on this server (512 MB virtual instance really should be bigger). Halting the IPython notebook server and repeating the apt commands was successful.


Solution 1:

I experienced the same problem and solved it with sudo dpkg-reconfigure libapt-pkg4.12

source: http://www.schakko.de/2013/08/11/fixing-segmentation-fault-in-libapt-pkg/

Solution 2:

It seems that your apt cache file is corrupted.

Open terminal and run following commands.

  • First remove the cache file.

    sudo rm  /var/cache/apt/*.bin
    
  • Now re-create it using

    sudo apt-get update
    sudo apt-get upgrade