Bug 109913 - rpm segfaults, corrupts Packages db, cannot recover!
rpm segfaults, corrupts Packages db, cannot recover!
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
1
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Paul Nasrat
Mike McLean
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-11-12 16:30 EST by Torrey Hoffman
Modified: 2007-11-30 17:10 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-04-19 15:06:59 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Torrey Hoffman 2003-11-12 16:30:54 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1)
Gecko/20031030

Description of problem:
RPM segfaults while installing a package, and corrupts the "Packages"
database.  From that point on, rpm seems to be permanently messed up,
with no obvious way to recover.  

Running any rpm command, including rpm --rebuilddb hangs, and it must
be killed with -9.

For instance:

# rpm -v -v --rebuilddb
D: rebuilding database /var/lib/rpm into /var/lib/rpmrebuilddb.2274
D: creating directory /var/lib/rpmrebuilddb.2274
D: opening old database with dbapi 3
D: opening  db environment /var/lib/rpm/Packages joinenv
D: opening  db index       /var/lib/rpm/Packages rdonly mode=0x0

(and it dies here.)

Version-Release number of selected component (if applicable):
rpm-4.2.1

How reproducible:
Sometimes

Steps to Reproduce:
1. Install Fedora Core (the "Everything" install) and then install a
bunch of other RPMs (from FreshRPMs.net or whatever.)
2. Eventually rpm will segfault while installing an RPM and corrupt
it's database.
3. Future rpm commands hang.
    
Actual Results:  rpm hangs after opening the Packages database.

If I "mv /var/lib/rpm/Packages /var/lib/rpm/Packages.corrupt"

then rpm --rebuilddb works, but doesn't actually rebuild the database.
 It produces a new Packages file which is only about 12K (the
corrupted Packages file was over 50 MB)

Expected Results:  

1. rpm should NOT segfault when installing any RPM.

2. rpm should NOT corrupt it's database.

3. rpm --rebuilddb should actually rebuild the database, instead of
doing whatever useless thing it actually did.

4. rpm should probably keep backup copies of it's databases around, so
it can recover better from these catastrophic corruption problems.

Additional info:

I'd really like to know how to fix this problem without having to
reinstall Fedora!
Comment 1 Michael Young 2003-11-12 16:51:21 EST
See http://www.rpm.org/hintskinks/repairdb/ which includes
instructions on how to fix the Packages file. But first it might be
worth trying rpm --rebuilddb on your original Packages file when the
__db* files are removed (if you haven't already tried this).
Comment 2 Need Real Name 2003-11-18 20:20:38 EST
rpm --import does not look too happy, either.

# rpm -q rpm
rpm-4.2.1-0.30.1
# rpm -q beecrypt
beecrypt-3.0.1-0.20030630.1
# rpm -qf /lib/libc.so.6
glibc-2.3.2-4.80.8
# rpm -qa gpg-pubkey*
# gpg /tmp/fedo.txt 
pub  1024D/4F2A6FD2 2003-10-27 Fedora Project <fedora@redhat.com>
sub  1024g/FB939E34 2003-10-27 
# rpm --import /tmp/fedo.txt 
# rpm -qa gpg-pubkey*
error: rpmdbNextIterator: skipping h#     761 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     473 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     664 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     282 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     474 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     663 Header V3 DSA signature:
BAD, key ID db42a60e
gpg-pubkey-db42a60e-3f9d9db6
# rpm -qf /lib/libc.so.6 
error: rpmdbNextIterator: skipping h#     663 Header V3 DSA signature:
BAD, key ID db42a60e
# rpm -qi gpg-pubkey-db42a60e-3f9d9db6
Name        : gpg-pubkey                   Relocations: (not relocateable)
Version     : db42a60e                          Vendor: (none)
Release     : 3f9d9db6                      Build Date: Wed Nov 19
03:09:56 2003
Install Date: Wed Nov 19 03:09:56 2003      Build Host: localhost
Group       : Public Keys                   Source RPM: (none)
Size        : 0                                License: pubkey
Signature   : (none)
Summary     : gpg(Fedora Project <fedora@redhat.com>)
Description :
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: rpm-4.2.1 (beecrypt-3.0.0)

mQGiBD+dnTsRBACwnlz4AhctOLlVBAsq+RaU82nb5P3bD1YJJpsAce1Ckd2sBUOJD11NUCqH
8c7EctOquOZ5zTcWxHiWWbLyKQwUw2SUvnWa5SSbi8kI8q9MTPsPvhwtgMrQMLenMO+nsrxr
SaG6XcD+ssfJNxC7NQVCQAj3pvvg9rKi3ygsM7CXHwCghgsqX6TOr55HE90DbEsoq3b/jjsD
/i8aIZ6urUgrpAkQslcakXdJLKgSdwjRUgVZgvYZb7kAx1iPq0t/AhB3NJw3zW4AAKJohGg3
xj5K4V8PJEZrSIpoRYlF43Kqlfu2p5ghWT89SP4YAlWPeTqf0+dTYUYz3b144k2ZFOdRuXIR
xunoYNAUr9oMrxBXbJ/eY+0UQX3pBACYzKizyY4JJgd0zFJmNkcdK9nzcm+btYFnYQo33w5G
SE686UNr+9yiXt9tmPRvNEbj3u+xoAX8B/5k3aZ5NbUhV64/VcKlUdRIxNlFCG7I9KgxeHWA
Ywi7yqOGXM3T/v6o7GLdQEB0ChFqS7kUlqmwLV+C3QhlrFe/Cuk26i+Q6rQiRmVkb3JhIFBy
b2plY3QgPGZlZG9yYUByZWRoYXQuY29tPohGBBARAgAGBQI/ntjgAAoJECnVuiSN9W0FUSUA
oJnrone4J0o1HMkRz+6g9KVuO2FyAJ0XyebOzVmI9U5OyOfnNmYV0wnQcohGBBMRAgAGBQI/
nZ22AAoJECGRgM3bQqYOR5QAoIp1G+omVktq/snxpmz5UeHjlSYjAKCRr/ea/L7S7ZTxB18c
f1TYfad1x4hbBBMRAgAbBQI/nZ07BgsJCAcDAgMVAgMDFgIBAh4BAheAAAoJELRCadBPKm/S
2PAAnRTlhorITphab+oxAHtbxZF9BVyDAJ9WOVaZUG53IWWIAXOGv3j/cmr3lrkBDQQ/nZ08
EAQAugOfLWJbKwMA9vg2mJU594TZU0HRJkx/fqYhx0YxWWRpzplrEyvcDXuYcWi1Hwh0tD86
T4fR5GV6joWiWClzD+Hwhhb6gcSdeSGlGLlZAvWYtFSHWiv+3LaI9w8Vtczl99Bh2WiMDNDD
Gw0RQg6ZaftldLSe4j1pffpFGQ8SuisAAwUEAKVxqLT7fC5xQ6oclcZ+PhoDlePQ1BiTS7tu
GM07bFF4nNvY91LL7S31pooz3XbGSWP8jxzSv1Fw35YhSmWGOBOEXluqMbVQGJJ5m8fqJOjC
0imbfeWgr/T7zLrJeiljDxvX+6TyawyWQngF6v1Hq6FRV0O0bOp9Npt5zqCbDGs/iEYEGBEC
AAYFAj+dnTwACgkQtEJp0E8qb9L//gCcDVYnDegNCOxDn1sedDwxw+0h8OcAn1CZHof15Qqx
nTwEnvwF2QeOI5dn
=7hyK
-----END PGP PUBLIC KEY BLOCK-----



I have older RH, not all-Fedora...

Comment 3 Jeff Johnson 2003-12-05 11:12:19 EST
Try removing (or renaming) the /var/lib/rpm/Pubkeys index,
and then doing rpm --rebuilddb -vv. This is essentially the
same as adding --nosignature the hard way.

Then repeat "rpm -qa" to see if segfault is fixed.
Comment 4 Need Real Name 2003-12-05 12:38:15 EST
did you notice that comment was added by other guy than Torrey Hoffman...
I am not having segfaults, "only" database corruption.

# rpm -qa gpg-pubkey*
# rpm --import /tmp/4F2A6FD2.txt
# rpm -qa gpg-pubkey*
error: rpmdbNextIterator: skipping h#     192 Header V3 DSA signature:
BAD, key ID db42a60e
gpg-pubkey-db42a60e-3f9d9db6
error: rpmdbNextIterator: skipping h#     553 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     457 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     311 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     503 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     191 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     388 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     533 Header V3 DSA signature:
BAD, key ID db42a60e
error: rpmdbNextIterator: skipping h#     357 Header V3 DSA signature:
BAD, key ID db42a60e

# rpm --checksig glibc-2.3.2-4.80.i686.rpm 
glibc-2.3.2-4.80.i686.rpm: (SHA1) DSA sha1 md5 GPG NOT OK

but
rm -f /var/lib/rpm/Pubkeys && rpm --rebuilddb -vv
did not make any difference, so I'll just replace these broken
database files from backup I made ten mins ago
and ignore every signature verification failure and hope packages are
not being tampered with.

# sha1 glibc-2.3.2-4.80.i686.rpm 
SHA1(glibc-2.3.2-4.80.i686.rpm)= cf8b3b3a67bf8a011f083177fe081389f4590988
Comment 5 Dag Wieers 2004-01-31 22:51:39 EST
I have a similar case where removing the Pubkeys file and rebuilding
rpmdb was a solution. My feeling is that it seems to be caused by
importing keys and it might has something to do with apt-get.

Note You need to log in before you can comment on or make changes to this bug.