Bug 214738 - rrdtool library functions cannot be called multiple times
rrdtool library functions cannot be called multiple times
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: rrdtool (Show other bugs)
3
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jarod Wilson
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-11-08 22:58 EST by i.goyret
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-11-22 14:21:09 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
patch to correct the getopt() problem for rrdtool-1.0.49 (3.20 KB, patch)
2006-11-08 22:58 EST, i.goyret
no flags Details | Diff
patch to correct the getopt() problem for rrdtool-1.0.50 (3.29 KB, patch)
2006-11-08 23:00 EST, i.goyret
no flags Details | Diff

  None (edit)
Description i.goyret 2006-11-08 22:58:24 EST
Description of problem:

I have a C program linked to librrd.so that does something like this:
   if ( rrdfile doesn't exist )
       call rrd_create()

   call rrd_update()

If rrd file does not exist, the call to rrd_update() will fail
with really odd results (trying to open a file with a name that
suspiciously matches one of the new values).


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

  rrdtool-1.0.49-4.fc3 and rrdtool-devel-1.0.49-4.fc3

How reproducible:

Every single time.

Steps to Reproduce:
1. create a C program like mentioned above
2. make sure the rrd file does not exist
3. run the program --> rrd_update() will fail.
   Note that the rrdfile was created successfully.

4. now run the program again --> rrd_update() works fine.
  
Actual results:



Expected results:


Additional info:

The problem is apparently a well known problem with rrdtool.
I found messages as early as 2002 referring to this problem.
The issue is that all the rrdtool functions in librrd.so
use getopt_long() but none of the functions initialize
optind and opterr.

The solution to this problem is trivial: initialize optind
and opterr right before calling any of the rrd_*() functions
in librrd.so. Of course, you first need to waste a day's work
debugging this problem only to find out that it is a well
known problem.

The _CORRECT_ solution to this problem is to initialize optind
and opterr right before calling getopt_long() the first time
on each function _IN_ librrd.so. The calling programs shouldn't
need to know how librrd is implemented.

See attached patches for rrdtool-1.0.49-4 and rrdtool-1.0.50
Comment 1 i.goyret 2006-11-08 22:58:24 EST
Created attachment 140742 [details]
patch to correct the getopt() problem for rrdtool-1.0.49
Comment 2 i.goyret 2006-11-08 23:00:25 EST
Created attachment 140743 [details]
patch to correct the getopt() problem for rrdtool-1.0.50

This is the patch for rrdtool-1.0.50, as used in FC5.
Comment 3 Jarod Wilson 2006-11-09 14:36:13 EST
Fedora Core 4 and older have all been retired, and new builds are frowned upon
unless they address severe bugs or security issues.

http://fedoraproject.org/wiki/Extras/Policy/EOL

Is there really a compelling reason here to update a package for something as
old as FC3?

As for FC5, rrdtool is already updated to 1.2.15.
Comment 4 i.goyret 2006-11-22 14:15:11 EST
I guess there is no big compelling reason once you know how to work around the
bug. In my case, this bug wasted two days of my time only to find out that I had
stumbled upon a very old bug (and apparently, well known).
If anyone finds themselves in the same boat, at least the patches and the
information here will provide the info they need.
Thanks for your attention.
Comment 5 Jarod Wilson 2006-11-22 14:21:09 EST
Sounds good to me.

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