Bug 114622 (rpm_endless_looping)

Summary: rpm enters into an endless loop when there is a damaged header in the rpmdb
Product: [Retired] Red Hat Linux Reporter: Matthew Williams <rhbugzilla>
Component: rpmAssignee: Paul Nasrat <nobody+pnasrat>
Status: CLOSED CURRENTRELEASE QA Contact: Mike McLean <mikem>
Severity: high Docs Contact:
Priority: medium    
Version: 9CC: rhbugzilla
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-04-19 18:45:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Matthew Williams 2004-01-30 11:32:15 UTC
Description of problem:
rpm enters into an endless loop when performing a query(--query) and 
there is a damaged header in the rpmdb. rpmq becomes a runaway 
process that cannot be killed using Ctrl+C or using kill [rpmq 
process number], it can be killed using kill -9 [rpmq process number].

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


How reproducible:
Hopefully this is easily reproducible, I will list all the steps I 
took before I got the error. In case it is not easily reproducible I 
will attach the rpm database files and from them you should hopefully 
be able to work out the cause of the problem.

Steps to Reproduce:
1. I installed the following packages(from the RH9 RPM dirs) which 
were in a unique directory using this command:
rpm -Uvh --oldpackage ./*.rpm
dietlibc-0.21-4.i386.rpm
glib2-devel-2.2.1-1.i386.rpm
glibc-2.3.2-11.9.i386.rpm
glibc-common-2.3.2-11.9.i386.rpm
glibc-debug-2.3.2-11.9.i386.rpm
glibc-devel-2.3.2-11.9.i386.rpm
glibc-kernheaders-2.4-8.10.i386.rpm
glibc-profile-2.3.2-11.9.i386.rpm
glibc-utils-2.3.2-11.9.i386.rpm
glib-devel-1.2.10-10.i386.rpm
rpm-build-4.2-0.69.i386.rpm
rpmdb-redhat-9-0.20030313.i386.rpm
rpm-devel-4.2-0.69.i386.rpm
rpm-python-4.2-0.69.i386.rpm
2. I installed the following packages(from the RH9 RPM dirs) which 
were in another unique directory using this command:
rpm -Uvh --replacepkgs ./*.i686.rpm
glibc-2.3.2-11.9.i686.rpm
3. I installed the following packages(from the RH9 RPM dirs) which 
were in another unique directory using this command:
rpm -Uvh ./*.rpm
glibc-2.3.2-27.9.7.i386.rpm
glibc-common-2.3.2-27.9.7.i386.rpm
glibc-debug-2.3.2-27.9.7.i386.rpm
glibc-devel-2.3.2-27.9.7.i386.rpm
glibc-profile-2.3.2-27.9.7.i386.rpm
glibc-utils-2.3.2-27.9.7.i386.rpm
4. I installed the following packages(from the RH9 RPM dirs) which 
were in another unique directory using this command:
rpm -Uvh --replacepkgs ./*.i686.rpm
glibc-2.3.2-27.9.7.i686.rpm
5. I then tried to install the pmake-1.45-10.i386.rpm pachake using 
this command:
rpm -Uvh --test pmake-1.45-10.i386.rpm
and got this error:
error: Failed dependencies:
        libc.so.6 is needed by pmake-1.45-10
        libc.so.6(GLIBC_2.0) is needed by pmake-1.45-10
        libc.so.6(GLIBC_2.1) is needed by pmake-1.45-10
        libc.so.6(GLIBC_2.2) is needed by pmake-1.45-10
        libc.so.6(GLIBC_2.3) is needed by pmake-1.45-10
    Suggested resolutions:
        glibc-2.3.2-11.9.i386.rpm
6. So I tried to query the rpm database using:
rpm --query glibc
which would return me to the command prompt straight away with no 
output text at all which was strange.
7. I queried the rpm database again, this time being a bit more 
specific:
rpm --query glibc-2.3.2-27.9.7.i686
and bang, rpm got stuck in an endless loop always outputting:
error: rpmdb: damaged header #382 retrieved -- skipping.
  
Actual results:
[root@wilber root]# rpm --query glibc
[root@wilber root]# 
^^^^^ The first time I ran that command it took me straight back to 
the prompt without any output.

[root@wilber root]# rpm --query glibc-2.3.2-27.9.7.i686
error: rpmdb: damaged header #382 retrieved -- skipping.
error: rpmdb: damaged header #382 retrieved -- skipping.
error: rpmdb: damaged header #382 retrieved -- skipping.
error: rpmdb: damaged header #382 retrieved -- skipping.
....
^^^^^ That above line keeps repeating forever. Ctrl + C and kill have 
no effect. The process can be killed using kill -9. The following 
query terms also have the same effect ie endless looping:
glibc-2.3.2-27.9.7.i686.rpm
glibc-2.3.2-27.9.7
glibc-

[root@wilber root]# rpm --query glibc
error: rpmdbNextIterator: skipping h#     382 region trailer: BAD, 
tag 29213 type 65 offset -269 count 6
[root@wilber root]# 
^^^^^ Weird. That output was never there the first time I ran that 
query, in fact there was no output the first time I ran that query.

Expected results:
[root@wilber root]# rpm --query glibc
glibc-2.3.2-27.9.7
[root@wilber root]# 

Additional info:
I will attach my rpm database files in a gzipped format just in case 
you are unable to reproduce the error. From looking at the rpm 
database you should hopefully be able to fix the error.

Comment 1 Matthew Williams 2004-01-30 14:14:08 UTC
Attachment was too big to attach(>5MB).
There are two .bz2 files, which contain the rpm database files as 
there were two directories which held rpm database files and I wasn't 
sure which was the correct directory.

http://wilber.pointclark.net/_usr_lib_rpmdb_i386-redhat-
linux_redhat_.tar.bz2
http://wilber.pointclark.net/_var_lib_rpm_.tar.bz2

application/x-bzip2

The _usr_lib_rpmdb_i386-redhat-linux_redhat_.tar.bz2 file is 20MB 
compressed and 74MB uncompressed. The _var_lib_rpm_.tar file is 5.3MB 
compressed and 22MB uncompressed. The filenames are in the format 
that a forwardslash was replaced with an underscore. Use these files 
if you are unable to reproduce the bug as these files would contain 
the rpm database with the damaged header.

Comment 2 Matthew Williams 2004-01-30 14:32:55 UTC
With Step 1 I should mention that these rpm's were already installed 
before I did rpm -Uvh --oldpackage ./*.rpm:
glib-1.2.10-10.i386.rpm
glib2-2.2.1-1.i386.rpm
glibc-2.3.2-27.9.7.i386.rpm
glibc-2.3.2-27.9.7.i686.rpm
glibc-common-2.3.2-27.9.7.i386.rpm
rpm-4.2-0.69.i386.rpm

glibc-2.3.2-27.9.7.i386.rpm
glibc-2.3.2-27.9.7.i686.rpm
^^^^^ With these two I am not certain if both were definetely 
installed but I am certain the .i686 one was.

Comment 3 Matthew Williams 2004-02-01 02:16:00 UTC
One question would be what corrupted the rpmdb in the first place? I 
suspect it was one of the *lib* rpms I installed.

Is there a tool that scans the rpmdb and fixs any errors it comes 
across?

Comment 4 Jeff Johnson 2004-02-01 12:47:18 UTC
*** Bug 114714 has been marked as a duplicate of this bug. ***

Comment 5 Jeff Johnson 2004-02-01 13:14:05 UTC
Sure there's a tool. Have you tried
    rpm --rebuilddb -vv
I do not see it in the volume of imformation above.

Before --rebuilddb, you migh want to do
    cd /var/lib/rpm
    /usr/lib/rpm/rpmdb_verify Packages

If that fails, then
    cd /var/lib/rpm
    mv Packages Packages-ORIG
    /usr/lib/rpm/rpmdb_dump Packages-ORIG | /usr/lib/rpm/rpmdb_load
Packages
should fix. Recheck with rpmdb_verify.

Then rpm --rebuilddb -vv to recreate indices.

Comment 6 Jeremy Katz 2005-04-19 18:45:59 UTC
Closing due to inactivity.  If this issue still occurs with current releases,
please reopen and set the release in which you've encountered the problem.