Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 153163 - lib/poptQV.c::rpmQVSourceArgCallback() is called twice for each query arg
Summary: lib/poptQV.c::rpmQVSourceArgCallback() is called twice for each query arg
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: rpm
Version: 3.0
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Paul Nasrat
QA Contact: Mike McLean
Depends On:
TreeView+ depends on / blocked
Reported: 2005-04-01 21:53 UTC by James Olin Oden
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2006-02-12 18:44:58 UTC
Target Upstream Version:

Attachments (Terms of Use)

Description James Olin Oden 2005-04-01 21:53:10 UTC
Description of problem:
I have to say this is really, bizarre, but I was trying to add a --target 
option to:

   rpm -q --specfile blah.spec

as in:

   rpm -q --specfile blah.spec --target ia32e

And when I ran the query I would always end up with the query ran twice.
I eventually added debug code in rpmQVSourceArgCallback(), and noted that for 
every --target I added the callback would be called twice.   I then added 
debug output to the part of the case statement that handled --specfile, and 
found that it indeed was called twice for that too.  So it seems like 
the query args callback gets called twice for each query arg.

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

How reproducible:

Steps to Reproduce:
1.  Patch lib/poptQV.c::rpmQVSourceArgCallback() to do debug print for each
    part of the case statement.
2.  Run a query with this rpm you build.
Actual results:

It will print a debug message twice for each command line arg.

Expected results:

It should only print it once.

Additional info:
The problem seems to be masked in that most of the query args only take one 
arg, and thus memory is just reallocated each time, and the old string is lost.
I bet if you ran it through valgrind though you would at least note a memory 
leak on --specfile when on the second call it doesn't free() the initial memory 
it allocated.

Obviously, everything "works" right now, so I put this as a low priority bug.

Comment 1 James Olin Oden 2005-04-04 13:19:16 UTC
I looked at this further, and the reason this occurs is that there is a "popt" 
table defined called rpmQVSourcePoptTable.  This table is included in both 
rpmQueryPoptTable[], and rpmVerifyPoptTable[].  The end result is that 
any options defined in this table get acted on twice. 

In my case I simply needed to add my option to rpmQueryPoptTable, as it made 
since for it to be used by -V.   I still kind of think this is a bug, albeit a 
very minor one.  I am not sure how you would work around it though, as it would 
have to occur in popt itself.  Maybe, popt should keep a record of what 
callbacks it has made and not make them twice.  I see what is being done in the 
code (basically avoiding declaring this information twice), so it seems 
reasonable popt should support this without unexpected/likely unwanted side 

Comment 2 Jeff Johnson 2006-02-12 18:44:58 UTC
Tables need to be called multiple times because of multiple usages of various
options like -i and --target. There's no avoiding the aliasing except by making
the options unique per table.

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