When LIBC Is Broken

From ArchWiki

Jump to: navigation, search


Well, I am seeing how Ubuntu is getting out of a bad move where most binaries (bash included) are broken due to a bad libc package. And I was thinking, nice, need to keep some doc on this somewhere.

The problem and there solution is at: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/201673

I am mostly recopying an email here: In glibc 2.7-9ubuntu1, many critical programs (such as bash and sudo) fail to run with various error messages, such as "malloc: ../bash/subst.c:3472: assertion botched" from bash and "*** glibc detected *** sudo: free(): invalid pointer: 0xb7fabb70 ***" from sudo. This renders the system unusable. This bug was introduced due to changes in the default value of LDFLAGS for package builds; while these changes were useful and had been tested elsewhere, they unexpectedly broke the C library when it was next built.

Never do the following, this is just for learning some tricks.

The quickest workaround is to copy an older version of the C library from the initramfs. This will work provided you upgraded from a relatively recent version of Hardy, so that the initramfs really does have an older version. DO NOT do this if you encountered this bug immediately after upgrading from Ubuntu 7.10 or earlier, as it will break your system badly. Reboot if necessary, and follow these steps:

* Press Escape at start-up time to access the GRUB menu (this is not
 necessary on all systems)
* Press 'e' to edit the normal Ubuntu boot options
* Use the cursor keys to reach the line starting with 'kernel'
* Press 'e' again to edit the boot command line
* Change 'ro' to 'rw', remove 'splash', and add 'break=bottom' (without
 the quotes) to the end of the boot options
* Press Enter and then 'b' to start up
* After a few moments, you will be presented with an '(initramfs)'
 prompt
* Type the following (you may see some 'No such file or directory'
 messages after running the cp command, which you can safely ignore):
   mount -o remount,rw /root
   cp /lib/libc.so.6 /lib/libdl.so.2 /lib/libm.so.6 /lib/libpthread.so.0 /lib/librt.so.1 /root/lib/
   # run the following on the 32-bit PC edition (i386)
   cp /lib/ld-linux.so.2 /root/lib/
   # run the following on the 64-bit PC edition (amd64)
   cp /lib64/ld-linux-x86-64.so.2 /root/lib64/
   umount /root
   reboot
* Start up normally

If this does not work, or if you encountered this bug immediately after upgrading from Ubuntu 7.10 or earlier, then you will need to follow the steps below instead.

If you have turned off your system, then you will be unable to start up and log in normally. In that case, get hold of a Hardy Alpha 6 desktop CD (since you are running a development version of Ubuntu, this should be reasonable); you can download it from http://cdimage.ubuntu.com/releases/hardy/alpha-6/ if you do not have one to hand, and follow these steps:

* Start up from the desktop CD
* Run Applications -> Accessories -> Terminal (GNOME) or K-Menu ->
 System -> Konsole (KDE)
* If you are running the 32-bit PC (i386) edition of Ubuntu, type the
 following into the terminal window:
   wget http://launchpadlibrarian.net/11110565/libc6_2.7-5ubuntu2_i386.deb
* If you are running the 64-bit PC (amd64) edition of Ubuntu, type the
 following into the terminal window:
   wget http://launchpadlibrarian.net/11109997/libc6_2.7-5ubuntu2_amd64.deb
* If you are running some other edition of Ubuntu, older packages may
 be available from http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/
* In any case, continue by finding out the device name for your root
 partition, which will look something like '/dev/sda1'. You can run
 'sudo fdisk -l' to find out all the available device names. The one
 you want will have 'Linux' in the 'System' column. A default
 installation will only have one such device; if you have more than
 one, then you probably know what you are doing!
* Type the following into the terminal window, replacing DEVICE with
 the device name you found above:
   sudo mount DEVICE /mnt
   sudo mount --bind /dev /mnt/dev
   sudo mount --bind /proc /mnt/proc
   sudo cp libc6_*.deb /mnt/tmp/
   # replace 'i386' with 'amd64' if you are running the 64-bit PC edition
   sudo chroot /mnt dpkg -i /tmp/libc6_2.7-5ubuntu2_i386.deb
   # this step may return some errors; don't worry about them
   sudo chroot /mnt dpkg --configure -a
   sudo umount /mnt/proc
   sudo umount /mnt/dev
   sudo umount /mnt
* Reboot
Personal tools