Bug 214738 - rrdtool library functions cannot be called multiple times
Summary: rrdtool library functions cannot be called multiple times
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: rrdtool
Version: 3
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jarod Wilson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-11-09 03:58 UTC by i.goyret
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-11-22 19:21:09 UTC
Type: ---
Embargoed:


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

Description i.goyret 2006-11-09 03:58:24 UTC
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-09 03:58:24 UTC
Created attachment 140742 [details]
patch to correct the getopt() problem for rrdtool-1.0.49

Comment 2 i.goyret 2006-11-09 04:00:25 UTC
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 19:36:13 UTC
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 19:15:11 UTC
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 19:21:09 UTC
Sounds good to me.


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