Bug#355047: apt tools segfault

2006-07-19 Thread Josep M. Perez Cancer
I found a way to work around the segfault. Looks like the culprits were 
/var/cache/apt/pkgcache.bin and /var/cache/apt/srcpkgcache.bin. For some 
reason they have been corrupted. Just removing them avoids the segfault.


I attach the versions of those files that crached the apt tools.

Josep M. Perez C.





pkgcache.bin
Description: Binary data


srcpkgcache.bin
Description: Binary data


Bug#355047: apt tools segfault

2006-07-14 Thread Josep M. Perez Cancer

Followup-For: Bug #355047
Package: apt
Version: 0.6.44.2

*** Please type your report below this line ***
apt-get and apt-cache segfault at the same program location. In the case
of apt-get, update finishes with a segfault and upgrade segfaults while
reading the package list. In the apt-cache case, just doing a search
triggers the segfault.

I have recompiled the package without optimisation and without
stripping and run it through gdb and strace.


-- Debugging session follows:
$ gdb apt-cache
GNU gdb 6.4.90-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain 
conditions.

Type show copying to see the conditions.
There is absolutely no warranty for GDB.  Type show warranty for details.
This GDB was configured as i486-linux-gnu...Using host libthread_db
library /lib/tls/i686/cmov/libthread_db.so.1.

(gdb) run search apt
Starting program: /usr/bin/apt-cache search apt

Program received signal SIGSEGV, Segmentation fault.
0xa7c60ca3 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0  0xa7c60ca3 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1  0xa7deb5c6 in std::string::compare () from /usr/lib/libstdc++.so.6
#2  0xa7e9ea7a in std::operator!=char, std::char_traitschar, 
std::allocatorchar  ([EMAIL PROTECTED], __rhs=0x0)
   at 
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/basic_string.h:2200
#3  0xa7f037d5 in debPackagesIndex::FindInCache (this=0x805b270, 
[EMAIL PROTECTED]) at deb/debindexfile.cc:308
#4  0xa7ecbb30 in CheckValidity ([EMAIL PROTECTED], 
Start={_M_current = 0x805c528}, End={_M_current = 0x805c55c}, 
OutMap=0xafb5afd8)

   at pkgcachegen.cc:580
#5  0xa7ece980 in pkgMakeStatusCache ([EMAIL PROTECTED], 
[EMAIL PROTECTED], OutMap=0xafb5afd8, AllowMem=true) at 
pkgcachegen.cc:715

#6  0x0804d307 in main (argc=3, argv=0xafb5b094) at apt-cache.cc:1791
(gdb) frame 3
#3  0xa7f037d5 in debPackagesIndex::FindInCache (this=0x805b270, 
[EMAIL PROTECTED]) at deb/debindexfile.cc:308

308   if (FileName != File.FileName())
(gdb) print FileName
$1 = {static npos = 4294967295, _M_dataplus = {std::allocatorchar = 
{__gnu_cxx::new_allocatorchar = {No data fields}, No data fields},
 _M_p = 0x805c884 
/var/lib/apt/lists/ftp.nl.debian.org_debian_dists_unstable_main_binary-i386_Packages}}

(gdb) print File
$2 = {Owner = 0xafb5aa94, File = 0xa7f44220}
(gdb) print File.Owner
$3 = (class pkgCache *) 0xafb5aa94
(gdb) print *File.Owner
$4 = {_vptr.pkgCache = 0x805a468, CacheFile = {static npos = 4294967295, 
_M_dataplus = {std::allocatorchar =
   {__gnu_cxx::new_allocatorchar = {No data fields}, No data 
fields}, _M_p = 0xa7e395bc }},
 Map = @0x805c6c8, HeaderP = 0xa7f42000, PkgP = 0xa7f42000, 
VerFileP = 0xa7f42000, PkgFileP = 0xa7f42000, VerP = 0xa7f42000,
 ProvideP = 0xa7f42000, DepP = 0xa7f42000, StringItemP = 0xa7f42000, 
StrP = 0xa7f42000 \230\004, VS = 0xa7f29ca4}

(gdb) print *File.File
$5 = {FileName = 0, Archive = 0, Component = 0, Version = 0, Origin = 0, 
Label = 0, Architecture = 0, Site = 0, IndexType = 0, Size = 0,

 Flags = 0, NextFile = 0, ID = 0, mtime = 0}
(gdb) up
#4  0xa7ecbb30 in CheckValidity ([EMAIL PROTECTED], 
Start={_M_current = 0x805c528}, End={_M_current = 0x805c55c}, 
OutMap=0xafb5afd8)

   at pkgcachegen.cc:580
580   pkgCache::PkgFileIterator File = (*Start)-FindInCache(Cache);
(gdb) frame 3
#3  0xa7f037d5 in debPackagesIndex::FindInCache (this=0x805b270, 
[EMAIL PROTECTED]) at deb/debindexfile.cc:308

308   if (FileName != File.FileName())
(gdb) print *this
$6 = {pkgIndexFile = {_vptr.pkgIndexFile = 0xa7f27048, Trusted = 
true}, URI = {static npos = 4294967295,
   _M_dataplus = {std::allocatorchar = 
{__gnu_cxx::new_allocatorchar = {No data fields}, No data fields},
 _M_p = 0x805bb44 http://ftp.nl.debian.org/debian/}}, Dist = 
{static npos = 4294967295,
   _M_dataplus = {std::allocatorchar = 
{__gnu_cxx::new_allocatorchar = {No data fields}, No data fields},

 _M_p = 0x805be5c unstable}}, Section = {static npos = 4294967295,
   _M_dataplus = {std::allocatorchar = 
{__gnu_cxx::new_allocatorchar = {No data fields}, No data 
fields}, _M_p = 0x805babc main}}}

(gdb)


-- strace output
$ strace apt-cache search apt
execve(/usr/bin/apt-cache, [apt-cache, search, apt], [/* 31 vars 
*/]) = 0

uname({sys=Linux, node=bscig02, ...}) = 0
brk(0)  = 0x805b000
access(/etc/ld.so.nohwcap, F_OK)  = -1 ENOENT (No such file or 
directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 
0) = 0xa7fab000
access(/etc/ld.so.preload, R_OK)  = -1 ENOENT (No such file or 
directory)

open(/etc/ld.so.cache, O_RDONLY)  = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=108031, ...}) = 0
mmap2(NULL, 108031, PROT_READ, MAP_PRIVATE, 3, 0) = 0xa7f9
close(3)= 0
access(/etc/ld.so.nohwcap, F_OK)  = -1