Bug 480510

Summary: [ppc64] Crash when called by rpm.ppc64
Product: [Fedora] Fedora Reporter: Jan Kratochvil <jan.kratochvil>
Component: compat-dbAssignee: Jindrich Novy <jnovy>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: low    
Version: rawhideCC: jnovy, loganjerry, pknirsch, pmatilai
Target Milestone: ---   
Target Release: ---   
Hardware: ppc64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-02-18 21:14:26 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:
Bug Depends On:    
Bug Blocks: 486423    

Description Jan Kratochvil 2009-01-18 00:12:06 UTC
Description of problem:
rpm.ppc64 crashes.  Commonly rpm.ppc is in use which works fine.
Backtrace points to compat-db (at least I hope it is not due to rpm.ppc64).

Version-Release number of selected component (if applicable):
compat-db45-4.5.20-5.fc10.ppc64
rpm-4.6.0-0.rc3.2.fc11.ppc64 (only use its extracted bin/rpm)

How reproducible:
Extract 

Steps to Reproduce:
1. approx.: rpm2cpio ../rpm-4.6.0-0.rc3.2.fc11.ppc64.rpm |cpio -id
2. ~/redhat/rpm-4.6.0-0.rc3.2.fc11.ppc64/bin/rpm -qf /bin/true

Actual results:
Segmentation fault

Expected results:
coreutils-7.0-5.fc11.ppc

Additional info:
$ gdb -nx -ex 'set build-id-verbose 0' -ex 'file ~/redhat/rpm-4.6.0-0.rc3.2.fc11.ppc64/bin/rpm' -ex 'run -qf /bin/true'
GNU gdb (GDB) Fedora (6.8.50.20081214-1.fc11)
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 "ppc64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Reading symbols from /root/jkratoch/redhat/rpm-4.6.0-0.rc3.2.fc11.ppc64/bin/rpm...Reading symbols from /usr/lib/debug/bin/rpm.debug...done.
done.
Starting program: /root/jkratoch/redhat/rpm-4.6.0-0.rc3.2.fc11.ppc64/bin/rpm -qf /bin/true
[Thread debugging using libthread_db enabled]
Detaching after fork from child process 26993.
Detaching after fork from child process 26994.
Detaching after fork from child process 26995.
Detaching after fork from child process 26996.
Detaching after fork from child process 26997.
Detaching after fork from child process 26998.

Program received signal SIGSEGV, Segmentation fault.
__db_des_get (dbenv=0x1005df70, env_infop=<value optimized out>, infop=0x1005e890, rpp=0xfffffffc490) at ../../env/env_region.c:1053
1053			if (rp->id == INVALID_REGION_ID) {
(gdb) bt
#0  __db_des_get (dbenv=0x1005df70, env_infop=<value optimized out>, infop=0x1005e890, rpp=0xfffffffc490) at ../../env/env_region.c:1053
#1  0x000000803a8bddf8 in __db_e_attach (dbenv=0x1005df70, init_flagsp=0xfffffffc5ec) at ../../env/env_region.c:264
#2  0x000000803a8bac1c in __env_open (dbenv=0x1005df70, db_home=<value optimized out>, flags=147456, mode=<value optimized out>) at ../../env/env_open.c:281
#3  0x000000803a8bb2e4 in __env_open_pp (dbenv=0x1005df70, db_home=0x1005df50 "/var/lib/rpm", flags=147456, mode=420) at ../../env/env_open.c:163
#4  0x000000803a648a04 in db_init (dbenvp=<value optimized out>, dbsubfile=<value optimized out>, dbfile=<value optimized out>, dbhome=0x1005df50 "/var/lib/rpm", dbi=<value optimized out>) at backend/db3.c:371
#5  db3open (rpmdb=0x1005d6f0, rpmtag=<value optimized out>, dbip=0xfffffffc838) at backend/db3.c:929
#6  0x000000803a651d7c in dbiOpen (db=0x1005d6f0, rpmtag=0, flags=<value optimized out>) at rpmdb.c:231
#7  0x000000803a653248 in openDatabase (prefix=<value optimized out>, dbpath=0x803a699270 "%{_dbpath}", _dbapi=<value optimized out>, dbp=0x1005ccf8, mode=<value optimized out>, perms=<value optimized out>, flags=0) at rpmdb.c:957
#8  0x000000803a68ba68 in rpmtsOpenDB (ts=0x1005ccb0, dbmode=0) at rpmts.c:100
#9  0x000000803a68be94 in rpmtsInitIterator (ts=0x1005ccb0, rpmtag=RPMTAG_NAME, keyp=0x803a6a0eb0, keylen=0) at rpmts.c:196
#10 0x000000803a68c0dc in loadKeyringFromDB (ts=<value optimized out>) at rpmts.c:336
#11 loadKeyring (ts=0x1005ccb0) at rpmts.c:371
#12 0x000000803a68be04 in rpmtsInitIterator (ts=<value optimized out>, rpmtag=RPMTAG_BASENAMES, keyp=0x100485d0, keylen=0) at rpmts.c:194
#13 0x000000803a6738b8 in rpmQueryVerify (qva=0x803a6bec08, ts=0x1005ccb0, arg=<value optimized out>) at query.c:492
#14 0x000000803a673f2c in rpmcliArgIter (ts=0x1005ccb0, qva=0x803a6bec08, argv=0x10017970) at query.c:634
#15 0x000000803a674328 in rpmcliQuery (ts=0x1005ccb0, qva=0x803a6bec08, argv=0x10017970) at query.c:672
#16 0x00000000100031ac in main (argc=3, argv=<value optimized out>) at rpmqv.c:762
(gdb) q

While rpm.ppc64 is not used gdb.ppc64 with the rpm-libs.ppc64 dependency is in use.  Temporary workaround for gdb.ppc64: -ex 'set build-id-verbose 0'

Comment 1 Panu Matilainen 2009-02-18 12:21:18 UTC
The crash should be gone as of current rawhide due to using db 4.7.x instead of 4.5.x. Doesn't mean the db environment can actually be shared between 32/64bit processes (you just get an error message instead), but that's really been the case AFAIK.

Comment 2 Jan Kratochvil 2009-02-18 21:14:26 UTC
Thanks, confirming as fixed:

$ rpm -qv rpm
rpm-4.6.0-4.fc11.ppc
$ ./rpm.ppc64/usr/bin/rpmquery -qv rpm
rpmdb: Build signature doesn't match environment
error: db4 error(-30971) from dbenv->open: DB_VERSION_MISMATCH: Database environment version mismatch
error: cannot open Packages index using db3 -  (-30971)
error: cannot open Packages database in /var/lib/rpm
rpmdb: Build signature doesn't match environment
error: db4 error(-30971) from dbenv->open: DB_VERSION_MISMATCH: Database environment version mismatch
error: cannot open Packages database in /var/lib/rpm
package rpm is not installed

gdb.ppc64 also no longer crashes.

Just the gdb rpmdb queries support does not work there due to rpmdb being in the ppc32 format.  I was not aware of this incompatibility.  Hmm.

Comment 3 Panu Matilainen 2009-02-19 09:02:14 UTC
There's an extra gotcha here: the *database* is 32/64bit portable, the db environment is not. Going through the environment is the means to safe concurrent access to the db, but it is only used/usable with sufficient permissions to the rpmdb directory. Otherwise "private" locking (which is just about as good as no locking, but mostly works for read-only purposes) is used:

[pmatilai@localhost ~]$ rpm -q --dbpath /var/lib/mock/fedora-rawhide-i386/root/var/lib/rpm/ glibc
glibc-2.9.90-3.i686
[pmatilai@localhost ~]$ su
Password: 
[root@localhost pmatilai]# rpm -q --dbpath /var/lib/mock/fedora-rawhide-i386/root/var/lib/rpm/ glibc
rpmdb: Build signature doesn't match environment
error: db4 error(-30971) from dbenv->open: DB_VERSION_MISMATCH: Database environment version mismatch
error: cannot open Packages index using db3 -  (-30971)
error: cannot open Packages database in /var/lib/mock/fedora-rawhide-i386/root/var/lib/rpm
rpmdb: Build signature doesn't match environment
error: db4 error(-30971) from dbenv->open: DB_VERSION_MISMATCH: Database environment version mismatch
error: cannot open Packages database in /var/lib/mock/fedora-rawhide-i386/root/var/lib/rpm
package glibc is not installed

In default Fedora setup, this equals to 32/64bit gdb accessing rpmdb working for regular users but not for root. Fun isn't it...