apt-get - Segmentation fault: Error Processing package libc-bin

Hi I am struggling with this for the past one month.

sudo apt-get upgrade and sudo apt-get autoremove is erroring out with following error

E: Unmet dependencies. Try using -f.

When I am running sudo apt-get install -f, it is erroring out as follows.

Fetched 30.2 MB in 32s (928 kB/s)                                              
Preconfiguring packages ...
Setting up libc-bin (2.23-0ubuntu9) ...
Segmentation fault
/sbin/ldconfig.real: Can't stat /lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /usr/lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/usr/local/lib' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
Segmentation fault
dpkg: error processing package libc-bin (--configure):
 subprocess installed post-installation script returned error exit status 139
Errors were encountered while processing:
 libc-bin
E: Sub-process /usr/bin/dpkg returned an error code (1)

1) The question is posted here link . But the answer mentioned is specific to the user.

2) As mentioned here link, I tried sudo apt-get --reinstall install libc-bin. But this is showing

E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

3) sudo dpkg --configure -a errors out as follows

Errors were encountered while processing:
 libosmesa6:i386
 libgl1-mesa-dri:i386
 libglapi-mesa:i386
 libgl1-mesa-glx:amd64
 libgl1-mesa-glx:i386
 libegl1-mesa:amd64
 xserver-xephyr
 xserver-xorg-core
 libgl1-mesa-dev:i386
 libwayland-egl1-mesa:amd64

Any help will be highly appreciated as this is a machine where all my academic projects are configured, so cannot afford a reinstall.

EDIT:

4) sudo dpkg --configure -D 777 libc-bin gives the following output:

D000001: ensure_diversions: new, (re)loading
D000001: process queue pkg libc-bin:amd64 queue.len 0 progress 1, try 1
D000040: checking dependencies of libc-bin:amd64 (- <none>)
D000400:   checking group ...
D000400:     checking possibility  -> libc6
D000400:       checking non-provided pkg libc6:amd64
D000400:       is installed, ok and found
D000400:     found 3
D000400:   found 3 matched 0 possfixbytrig -
D000400:   checking group ...
D000400:     checking possibility  -> libc6
D000400:       checking non-provided pkg libc6:amd64
D000400:       is installed, ok and found
D000400:     found 3
D000400:   found 3 matched 0 possfixbytrig -
D000040: ok 2 msgs >><<
D000040:     checking Breaks
D000400:       checking breaker locales:all virtbroken <none>
Setting up libc-bin (2.23-0ubuntu9) ...
D000002: fork/exec /var/lib/dpkg/info/libc-bin.postinst ( configure 2.23-0ubuntu9 )
Segmentation fault
/sbin/ldconfig.real: Can't stat /lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /usr/lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/usr/local/lib' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
Segmentation fault
dpkg: error processing package libc-bin (--configure):
 subprocess installed post-installation script returned error exit status 139
D000001: ensure_diversions: same, skipping
Errors were encountered while processing:
 libc-bin

EDIT:

5) I was trying the solution mentioned here link. But sudo mv /usr/lib/x86_64-linux-gnu/libtic.so.5.9 /root gives the error

mv: cannot stat '/usr/lib/x86_64-linux-gnu/libtic.so.5.9': No such file or directory

Does that mean that in my case some other library is causing the issue?

EDIT : I was able to do an strace during sudo apt-get install -f and the log is available here ; if that helps anyone.

6) I tried to increase the APT cache limit as mentioned here. But it did not help.

EDIT : Update Answer to Elder Geek's suggestions

7) I have tested my ram with memtest and it doesn't show any error. I have also conducted a SMART self test on my hard drive (short), which is showing that the "Disk is ok".

8) I have manually checked and this particular library /usr/lib/x86_64-linux-gnu/libtic.so.5.9 does not exist in the location. (So I believe that such a library is not existing in my system and some other library is causing the issue.)

9) I do not have the path /usr/lib/i686-linux-gnu in my system.

10) There was a Typo, I was checking /etc/apt/sources.lst as mentioned in the original answer. I do have a sources.list .

These are the entries I can see there. I dont see any ppa mentioned there.

deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu trusty partner
deb http://archive.ubuntu.com/ubuntu xenial main universe restricted
deb http://security.ubuntu.com/ubuntu/ xenial-security main restricted universe
deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe
deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe

Also I am unable to install any ppa manager since apt itself is broken and I am not able to install anything.

11) Additional info : This was originally a 14.04 system which was upgraded to 16.04. Those ppas I had in 14.04 were disabled during the upgrade. However, this upgrade happened almost a year ago and the system was running smoothly for almost an year now.

12) Last and most important: I remember performing a sudo apt-get dist-upgrade some time before all the problems started to appear. Can this be something which caused the issue?


While segmentation faults are normally associated with poorly written code attempting to access a restricted area of memory, I don't believe that's the cause of your issue. While it's not as common these faults can also be caused by misbehaving hardware. I would begin by ensuring that you have a stable environment by running memtest on your system and ensuring that your hdd is in good shape if you are using swap. If you discover faulty hardware, replace it.

Can't stat

means that the file or directory either doesn't exist or your user doesn't have access to it even via sudo. You can check permissions via the ls -l /lib/i686-linux-gnu command. Since there is no /usr/lib/i686-linux-gnu that I can find in a 64-bit version of Ubuntu (assumed based on Path /usr/lib/x86_64-linux-gnu given more than once ).

My best assessment based on the information you've provided is that the root cause to several of these errors is improper entries in your software sources. These are found in the /etc/apt/sources.lst file or the lists in the /etc/apt/sources.list.d directory. You might begin trying to clean it up with How can PPAs be removed?

If you are running a desktop with GUI, you might prefer Y PPA Manager which is a helpful tool for such tasks.

If there's anything confusing or unclear about this answer, please leave a comment and I'll do my best to clarify.

EDIT: Further assessment to cover additional points raised since this answer was originally written.

7) In the absence of faulty hardware we'll need to dig a bit deeper

8) abundantly clear since point 5.

9) Also clear since point 4.

Re-EDIT10) having a valid /etc/apt/sources.list means you don't need to replace it.

11) I have a system which was also upgraded from 14.04 to 16.04, my /etc/apt/sources.list is still intact as you now report your is.

12) That appears possible based on the bug mentioned by dessert in this comment.

At this point, the options are limited. Here they are in no particular order. Feel free to pick the one that seems least painful.

1) Revert to a previous backup

2) Backup user data (you should be doing this anyway) and install from scratch

3) Fix your installation. Download apt and all it's dependencies and reinstall them all with dpkg -i packagename