Bug 709421 - can't open rpm database after rpmcliFini()
Summary: can't open rpm database after rpmcliFini()
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: rpmreaper
Version: 15
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Lichvar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-05-31 17:16 UTC by Miroslav Lichvar
Modified: 2011-07-19 09:30 UTC (History)
4 users (show)

Fixed In Version: rpmreaper-0.1.6-8.fc15
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-06-11 04:30:31 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
reproducer (722 bytes, text/x-csrc)
2011-05-31 17:16 UTC, Miroslav Lichvar
no flags Details

Description Miroslav Lichvar 2011-05-31 17:16:26 UTC
Created attachment 502050 [details]
reproducer

Description of problem:
I'm getting strange errors in rpmreaper when the rpm database is read for second time. The package list is empty after pressing ctrl-R or a commit.

It seems to be caused by calling rpmcliInit/rpmcliFini twice, but I'm not sure if this is a bug in rpm or the client

Version-Release number of selected component (if applicable):
rpm-4.9.0-6.fc15.x86_64

How reproducible:
always

Steps to Reproduce:
1. run the attached reproducer
  
Actual results:
error: no dbpath has been set
error: cannot open Packages database in 
error: no dbpath has been set
error: cannot open Packages database in 

Expected results:
No error

Comment 1 Panu Matilainen 2011-06-01 06:21:41 UTC
(In reply to comment #0)
> I'm getting strange errors in rpmreaper when the rpm database is read for
> second time. The package list is empty after pressing ctrl-R or a commit.
> 
> It seems to be caused by calling rpmcliInit/rpmcliFini twice, but I'm not sure
> if this is a bug in rpm or the client

Mostly client error: you do not want to call these repeatedly under normal circumstances. You basically want to call rpmcliInit() early in main() and rpmcliFini() just before exit from main().

Rpm >= 4.9.0 frees more resources in rpmcliFini() than older versions did, so where the older versions leaked memory rpm now refuses to work on the second round as rpmcliInit() doesn't do anything on the second call because of a missing reset of "have we initialized yet" flag in rpmcliFini() (this was missing in older versions too but they "worked" because of the leaks). That's fixed upstream now, but rpmreaper should be changed not to do it anyway as I seriously doubt it has a "good" reason for doing it.

Comment 2 Miroslav Lichvar 2011-06-01 10:32:22 UTC
Ok, thanks.

IIRC the reason why rpmreaper did this is that originally there was no state preserved across rpmdb reads.

BTW, valgrind still reports some memory leaks from rpm. Again, this could be a bug in the client.

==21441== 26 bytes in 2 blocks are definitely lost in loss record 33 of 106
==21441==    at 0x4C2840D: malloc (vg_replace_malloc.c:236)
==21441==    by 0x744CF64: __os_malloc (in /lib64/libdb-4.8.so)
==21441==    by 0x744D053: __os_strdup (in /lib64/libdb-4.8.so)
==21441==    by 0x741FBEE: __env_config (in /lib64/libdb-4.8.so)
==21441==    by 0x7420BF9: __env_open (in /lib64/libdb-4.8.so)
==21441==    by 0x4E42067: ??? (in /usr/lib64/librpm.so.2.0.0)
==21441==    by 0x4E49362: ??? (in /usr/lib64/librpm.so.2.0.0)
==21441==    by 0x4E49878: ??? (in /usr/lib64/librpm.so.2.0.0)
==21441==    by 0x4E6E1E7: rpmtsOpenDB (in /usr/lib64/librpm.so.2.0.0)
==21441==    by 0x4E6E485: rpmtsInitIterator (in /usr/lib64/librpm.so.2.0.0)
==21441==    by 0x4E6E661: ??? (in /usr/lib64/librpm.so.2.0.0)
==21441==    by 0x4E6E4A1: rpmtsInitIterator (in /usr/lib64/librpm.so.2.0.0)

Comment 3 Fedora Update System 2011-06-02 06:37:37 UTC
rpmreaper-0.1.6-8.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/rpmreaper-0.1.6-8.fc15

Comment 4 Fedora Update System 2011-06-03 05:33:23 UTC
Package rpmreaper-0.1.6-8.fc15:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing rpmreaper-0.1.6-8.fc15'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/rpmreaper-0.1.6-8.fc15
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2011-06-11 04:30:25 UTC
rpmreaper-0.1.6-8.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Panu Matilainen 2011-07-19 09:30:00 UTC
Just FYI, rpm >= 4.9.1 (in rawhide, F15 update to follow) resets the cli-configured status on rpmcliInit()


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