I have a fairly urgent question (since release reliability might be
affected) for Maurice (or anyone else who feels they might have a chance to
understand plLibOpen) at the end.  This question came up as a natural
outgrowth of my setlocale investigations which I am reporting here
for everybody.

While waiting for the release I am still trying to figure out a solid way to
restore locale, but I am running into some really strange results.

The recommended method of saving and restoring locale is the following (see
http://developers.sun.com/dev/gadc/educationtutorial/creference/locale/locale.html):

/* Save original locale name */
char * locale_string_ptr=setlocale(LC_NUMERIC, NULL);

... do other specific setlocale commands, e.g.,

setlocale(LC_NUMERIC, "C");

/* Restore original locale using original locale name. */

setlocale(LC_NUMERIC, locale_string_ptr);

If I use the above idea in a simple test programme it works.  However,
valgrind reports invalid read errors for that final setlocale command so the
Linux implementation is problematic and at minimum will add a lot of
unacceptable noise to every single one of our valgrind reports.

If I use the above in cmap0_palette_read to save and restore whatever the
calling application uses for locale while using the "C" locale for the file
read, it works the first time, but on the second time cmap0_palette_read is
called, the string pointed to by locale_string_ptr is filled with garbage
(probably because of the problematic implementation noted above) and as a
result setlocale fails.  I debugged this with gdb, and the library call that
appears to generate the garbage is "fclose(fp);" in cmap0_palette_read.  If
I comment that out, then the logic succeeds, locale_string_ptr points to an
empty string and the setlocale call that restores locale succeeds (although
there are still a lot of serious valgrind errors reported for that call or
if I simply output the string).

Maurice (or somebody else here who understands the plLibOpen logic): could
you review the plLibOpen logic and confirm it is correct to close a file
opened that way with fclose?  The plLibOpen logic has been sitting around
as part of PLplot for ages, but it appears cmap0_palette_read and
plspal1 are our first attempts to ever use that logic which is why it
needs review by an expert (ideally before the release on Sunday).

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to