apt segfaults if /var/cache/apt/srcpkgcache.bin is wrong

Bug #57393 reported by fromport
26
This bug affects 2 people
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Won't Fix
Medium
Unassigned

Bug Description

Binary package hint: apt

edgy eft
apt-get update segfaults

root@dna:/var/tmp# apt-get update
Get:1 http://uk.archive.ubuntu.com edgy Release.gpg [189B]
[SNIP]
Hit http://uk.archive.ubuntu.com edgy-backports/multiverse Packages
Fetched 3B in 2s (1B/s)
Segmentation faultsts... 0%

Strace:
[SNIP]
stat64("/var/lib/apt/lists/uk.archive.ubuntu.com_ubuntu_dists_edgy-backports_Release.gpg", {st_mode=S_IFRE
G|0644, st_size=189, ...}) = 0
access("/var/cache/apt/", W_OK) = 0
write(1, "Fetched 3B in 1s (2B/s)\nReading "..., 48Fetched 3B in 1s (2B/s)
Reading package lists...) = 48
stat64("/var/cache/apt/pkgcache.bin", {st_mode=S_IFREG|0644, st_size=8967432, ...}) = 0
open("/var/cache/apt/pkgcache.bin", O_RDONLY) = 6
fcntl64(6, F_SETFD, FD_CLOEXEC) = 0
fstat64(6, {st_mode=S_IFREG|0644, st_size=8967432, ...}) = 0
mmap2(NULL, 8967432, PROT_READ, MAP_SHARED, 6, 0) = 0xb7308000
stat64("/var/lib/apt/lists/uk.archive.ubuntu.com_ubuntu_dists_edgy_main_binary-i386_Packages", {st_mode=S_
IFREG|0644, st_size=4609177, ...}) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Process 5936 detached

Revision history for this message
Carthik Sharma (carthik) wrote :

Thanks for your bug report. Could you please try to obtain a
backtrace by following the instructions on
       http://wiki.ubuntu.com/DebuggingProgramCrash.
This will greatly aid us in tracking down your problem.

You can add the backtrace as an attachment when responding to this request. Thanks in advance.

Changed in apt:
status: Unconfirmed → Needs Info
Revision history for this message
fromport (ubuntu-dth) wrote :

# apt-get install devscripts
Segmentation faultsts... 0%

No i can not give you more info.
I first had 8 hours of memtest86 to make sure it wasn't the hardware.

# procinfo
Linux 2.6.17-6-386 (root@rothera) (gcc [can't parse]) #??? 1CPU [dna.(none)]

Memory: Total Used Free Shared Buffers
Mem: 117980 112052 5928 0 2128
Swap: 249912 18140 231772

Bootup: Tue Aug 22 21:35:13 2006 Load average: 0.10 0.32 0.36 1/54 12514

user : 0:04:14.20 3.7% page in : 523641 disk 1: 47132r 22386w
nice : 0:24:42.73 21.8% page out: 377928
system: 0:02:45.65 2.4% page act: 77446
IOwait: 0:07:37.90 6.7% page dea: 65009
hw irq: 0:00:09.88 0.1% page flt: 5373322
sw irq: 0:00:09.09 0.1% swap in : 63
idle : 1:13:37.82 65.0% swap out: 4584
uptime: 1:53:19.44 context : 493033

irq 0: 1699222 timer irq 9: 1
irq 1: 2 irq 10: 142598 eth1
irq 2: 0 cascade [4] irq 11: 98987 acpi, uhci_hcd:usb1,
irq 7: 1 parport0 irq 12: 0 VIA686A
irq 8: 3 rtc irq 14: 69531 ide0

It's a VIA C3 with 128meg of memory and a 6 gig hd
It's not equipped to do any kind of compiling etc.
It's acting as a firewall for my cable connection
||/ Name Version Description
+++-====================-====================-========================================================
ii apt 0.6.45ubuntu5 Advanced front-end for dpkg
ii libc6 2.4-1ubuntu9 GNU C Library: Shared libraries

How to continue ?

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for your bugreport.

This sounds like your /var/cache/apt/pkgcache.bin and/or pkgsrccache.bin has been corrupted. Could you please try to delte those and see if that fixes the segfault?

Cheers,
 Michael

Changed in apt:
assignee: nobody → mvo
importance: Untriaged → Medium
Revision history for this message
fromport (ubuntu-dth) wrote :

[move *bin to backup directory]

# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  bsdutils coreutils initramfs-tools initscripts libiw28 libvolumeid0 mount sysv-rc sysvinit udev
  util-linux volumeid wireless-tools
13 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
Need to get 2772kB of archives.
After unpacking 156kB of additional disk space will be used.
Do you want to continue [Y/n]?

Yep ! that fixed it!
Isn't there a more polite way to fix corrupt .bin files than a segfault ?

Thanks a lot, sorry for the "noise"

Danny

Revision history for this message
unksi (unksi) wrote :

I have the very same problem, and for me deleting those 2 files do not make any difference. :(

omena@lappis:~$ sudo rm /var/cache/apt/pkgcache.bin /var/cache/apt/pkgsrccache.bin
rm: tiedostoa "/var/cache/apt/pkgsrccache.bin" ei voi poistaa: No such file or directory

omena@lappis:~$ sudo apt-get update
Nouda:1 http://fi.archive.ubuntu.com edgy Release.gpg [189B]
Löytyi http://fi.archive.ubuntu.com edgy/main Translation-fi
Nouda:2 http://security.ubuntu.com edgy-security Release.gpg [189B]
Siv http://security.ubuntu.com edgy-security/main Translation-fi
Siv http://fi.archive.ubuntu.com edgy/restricted Translation-fi
Löytyi http://fi.archive.ubuntu.com edgy/universe Translation-fi
Löytyi http://fi.archive.ubuntu.com edgy/multiverse Translation-fi
Nouda:3 http://fi.archive.ubuntu.com edgy-updates Release.gpg [189B]
Siv http://fi.archive.ubuntu.com edgy-updates/main Translation-fi
Siv http://fi.archive.ubuntu.com edgy-updates/restricted Translation-fi
Siv http://security.ubuntu.com edgy-security/restricted Translation-fi
Siv http://security.ubuntu.com edgy-security/universe Translation-fi
Siv http://security.ubuntu.com edgy-security/multiverse Translation-fi
Löytyi http://security.ubuntu.com edgy-security Release
Löytyi http://fi.archive.ubuntu.com edgy Release
Löytyi http://fi.archive.ubuntu.com edgy-updates Release
Löytyi http://security.ubuntu.com edgy-security/main Packages
Löytyi http://fi.archive.ubuntu.com edgy/main Packages
Löytyi http://fi.archive.ubuntu.com edgy/restricted Packages
Löytyi http://fi.archive.ubuntu.com edgy/main Sources
Löytyi http://security.ubuntu.com edgy-security/restricted Packages
Löytyi http://security.ubuntu.com edgy-security/main Sources
Löytyi http://security.ubuntu.com edgy-security/restricted Sources
Löytyi http://fi.archive.ubuntu.com edgy/restricted Sources
Löytyi http://fi.archive.ubuntu.com edgy/universe Packages
Löytyi http://fi.archive.ubuntu.com edgy/multiverse Packages
Löytyi http://fi.archive.ubuntu.com edgy/universe Sources
Löytyi http://fi.archive.ubuntu.com edgy/multiverse Sources
Löytyi http://fi.archive.ubuntu.com edgy-updates/main Packages
Löytyi http://fi.archive.ubuntu.com edgy-updates/restricted Packages
Löytyi http://fi.archive.ubuntu.com edgy-updates/main Sources
Löytyi http://security.ubuntu.com edgy-security/universe Packages
Löytyi http://security.ubuntu.com edgy-security/multiverse Packages
Löytyi http://security.ubuntu.com edgy-security/universe Sources
Löytyi http://security.ubuntu.com edgy-security/multiverse Sources
Löytyi http://fi.archive.ubuntu.com edgy-updates/restricted Sources
Noudettiin 3t ajassa 0s (4t/s)
Segmentation faulttteloita... 0%

Revision history for this message
unksi (unksi) wrote :

Its working now, there was a typo on the latter filename that I didnt spot at first.

Michael Vogt (mvo)
Changed in apt:
status: Needs Info → Confirmed
Revision history for this message
Christophe Dumez (hydr0g3n) wrote : Re: apt segfaults if /var/cache/apt/pkgcache.bin is wrong

I'm using Edgy and I had exactly the same problem during yesterday's update. Removing the *.bin files fixed the problem, thanks.

Revision history for this message
P (p92) wrote :

Same here after upgrade from dapper to edgy beta1
same workaround worked.

Revision history for this message
P (p92) wrote :

i'd like to try to produce a debug trace but i am unable to compile apt from source
see http://pastebin.com/797690

any clue ?

the corruption occured again and I had to delete the source cache to recover. It seems that fetching list of updates from adept does the corruption but i have to be sure.

Revision history for this message
P (p92) wrote :

see also Bug #61708

Revision history for this message
hackel (hackel) wrote :

Please elevate the importance of this bug report! An average user would have no clue what to do in this situation, and so apt/synaptic/etc. should properly detect and catch the problem to avoid a segfault and suggest to the user what to do, if not offer the option to automatically delete and rebuild the cache files.

In my case, I experienced this problem seemingly out of the blue. After some investigation, I downloaded and installed the libc6-dbg manually with dpkg, in order to get a proper backtrace. It appears, however, that the mere act of installing the -dbg package solved the problem! I don't understand it. I even made a backup of the offending *pkgcache.bin files, and even after removing libc6-dbg and replacing the original cache files, I still can't reproduce the problem. Perhaps the segfault wasn't even related to the pkgcache.bin files, but this seemed the most likely scenario.

Unfortunately, all I could get of it while it was happening was an strace and this mostly useless backtrace:

# gdb --args /usr/bin/apt-get -- install audacity
GNU gdb 6.8-debian
This GDB was configured as "x86_64-linux-gnu"...
(no debugging symbols found)
(gdb) r
Starting program: /usr/bin/apt-get -- install audacity
(no debugging symbols found)
Reading package lists... Done
Building dependency tree
Reading state information... Done
Program received signal SIGSEGV, Segmentation fault.
0x00007fe2f313aae0 in strcmp () from /lib/libc.so.6
(gdb) bt
#0 0x00007fe2f313aae0 in strcmp () from /lib/libc.so.6
#1 0x00007fe2f30f43f4 in ?? () from /lib/libc.so.6
#2-15 same as above with random addresses
#16 0x00007fe2f30f4771 in qsort () from /lib/libc.so.6
#17 0x00000000004067e6 in ?? ()
#18 0x0000000000418e60 in ?? ()
#19 0x00007fe2f3ded6ca in CommandLine::DispatchArg ()
   from /usr/lib/libapt-pkg-libc6.7-6.so.4.6
#20 0x000000000040855b in ?? ()
#21 0x00007fe2f30de1c4 in __libc_start_main () from /lib/libc.so.6
#22 0x0000000000406539 in ?? ()
#23 0x00007ffffc2a8a58 in ?? ()
#24 0x0000000000000000 in ?? ()

I will work on trying to reproduce this problem, but no luck so far.

Revision history for this message
Юрий Чудновский (fqc) wrote :

Having the same trouble.

root@frank-mobile:~# gdb --args /usr/bin/aptitude update
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
(no debugging symbols found)
(gdb) r
Starting program: /usr/bin/aptitude update
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0xb7a746d0 (LWP 5426)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7a746d0 (LWP 5426)]
0xb80c4006 in ?? () from /usr/lib/libapt-pkg-libc6.9-6.so.4.7
(gdb) bt
#0 0xb80c4006 in ?? () from /usr/lib/libapt-pkg-libc6.9-6.so.4.7
#1 0xec830008 in ?? ()
Cannot access memory at address 0xbd39c385

strace of apt-get upgrade:
...
open("/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jaunty_main_binary-i386_Packages", O_RDONLY) = 6
fcntl64(6, F_SETFD, FD_CLOEXEC) = 0
read(6, "Package: abiword\nPriority: option"..., 32768) = 32768
write(1, "\r\320\247\321\202\320\265\320\275\320\270\320\265 \321\201\320\277\320\270\321\201\3) = 50 списков пакетов... 0%277\320\260"..., 50
stat64("/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jaunty_main_binary-i386_Packages", {st_mode=S_IFREG|0644, st_size=7703897, ...}) = 0
fstat64(6, {st_mode=S_IFREG|0644, st_size=7703897, ...}) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

Trying to remove /var/lib/apt/ and/or /var/cache/apt/ did not fix trouble.

Technical info about system:

root@frank-mobile:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.04
Release: 9.04
Codename: jaunty
root@frank-mobile:~# uname -a
Linux frank-mobile 2.6.28-15-generic #52-Ubuntu SMP Wed Sep 9 10:49:34 UTC 2009 i686 GNU/Linux
apt 0.7.20.2ubuntu6

Got this problem after (successful on second run) apt-get upgrade.

Revision history for this message
Mossroy (mossroy) wrote :

I just had the same issue on a Ubuntu 10.04 Server (running inside VirtualBox), with all current updates.
The workaround also worked.

Revision history for this message
Mossroy (mossroy) wrote :

I have a snapshot of this virtual machine, that I made before applying the workaround.
So I might give you additional information if you need.
Unfortunately, the segmentation fault prevents me from installing gdb through apt-get.
You'll find in attached file the .bin files that I had to remove from /var/cache/apt

Revision history for this message
James Janssen (hystrix) wrote :

Just wanted to add that I experienced this after a new install of 10.4 on a new box.
It has been some time since I had installed Linux and was super impressed with how far Ubuntu has come.

* Clicked on "Update Manager" in the admin menu, it flashed up like it was going to load then disappeared
* Clicked on "Software Centre" same as above
* Opened a terminal and tried "aptitude"
Segfault

As an old time Linux user, my first guess when multiple programs are segfaulting is to assume bad hardware (I did not make the connection at this time that all of the programs were related to package management). I spent the next several hours running memory tests, disk tests and googling without a solution. I ran more tests from the Live CD and noticed that I was not getting any segfaults. So I booted in recovery mode from the hard drive and ran:

"apt-get upgrade"
output:
Reading package lists... Done
Segmentation faulty tree... 50%

Googling for this error yielded the following thread which provided me the solution:
http://ubuntuforums.org/showthread.php?t=803215

"sudo rm /var/cache/apt/*.bin"

After executing this delete I was able to finally run apt-get upgrade successfully.

Then If found this bug report, and was surprised that it has existed for 4 years through several Ubuntu releases.
I don't consider hand deleting the cache to be an acceptable work-around.

The box I was building was for someone who is not a Linux user and has no technical skills. It scares me that the cache could get corrupted (during install!) and the user has no recourse, since they are unable to update software.

Could this condition (unable to read apt cache binary files) on file open be caught and handled effectively?
- Error message to the user saying that something was wrong with the "temporary" files in the package manager and have them click through delete step; or
- Simply clearing the offending cache without telling the user; or at least
- A better error message with instructions on how to get help

hope this helps

Revision history for this message
Robbie Williamson (robbiew) wrote :

Please open a new bug, if this problem occurs for you on a supported release. Thanks!

Changed in apt (Ubuntu):
status: Confirmed → Won't Fix
assignee: Michael Vogt (mvo) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.