I have tagged the subject line with [Post-release] because I think it
is too late for for any but the most obvious and simple changes in
this release cycle, but I hope some of the memory management issues
that I am discovering right now for the tk device driver will be
addressed right away in the next release cycle.

I have discovered through the comprehensive tests of epa_build results
that I just implemented that examples/c/x01c -dev tk (and presumably
the rest of the C examples) segfault under a certain combination of
circumstances.

(1) Must be using the version of Tcl/Tk(8.6) built by epa_build.

(2) Must have -DUSE_TCL_TK_STUBS=ON

I know I did tests for this exact combination of circumstances in the
very recent past (via the test_interactive target which definitely
runs examples/c/x01c -dev tk and a lot of other tests) without a
segfault.  However, that is the nature of memory management issues;
some times you get segfaults and sometimes you don't.

When I ran valgrind on examples/c/x01c -dev tk for the above
combination of circumstances it showed an invalid read followed by a
segfault occurred at line 712 of bindings/tcl/tclAPI.c;

Tcl_SetVar( interp, "dir", TCL_DIR, TCL_GLOBAL_ONLY );

The TCL_DIR macro has not been clobbered according to the debug

fprintf( stderr, "adding %s to auto_path\n", TCL_DIR );

that occurs (now) just before that statement, and everything else
about this statement is pretty simple and benign so I don't understand
at all what is causing this segfault.  But it is a virtual certainty
it is caused by something being overwritten either in the heap or
stack.

Since -DUSE_TCL_TK_STUBS=ON is a new innovation that is not as well
tested as our traditional Tcl, etc., results which did not
use the stubs Tcl/Tk libraries, I have decided to work around
this issue for the default case by adopting -DUSE_TCL_TK_STUBS=OFF for
that case.

I then looked carefully at the -DUSE_TCL_TK_STUBS=OFF case with a
valgrind run on examples/c/x01c -dev tk.  For this non-stubs case
there were no obvious issues like invalid reads, but there were a fair
number of fouled up memory allocations by the time the example was
done as you can see from the attached valgrind report. Some of those
(such as at least the first two) are definitely due to PLplot code and
should be addressed by us post release just in case one of those is
the culprit that indirectly causes the invalid read and segfault
issues for the stubs case.

Of course, the issue might also be that PLplot can reliably use the
Tcl/Tk stubs libraries for Tcl/Tk version 8.5, but not 8.6 because of
our extensive use of of Tcl/Tk library API which has been deprecated
for many releases of Tcl/Tk and which therefore might not be reliably
maintained any more by the Tcl/Tk developers (say as of version 8.6).

@Arjen: To avoid such Tcl/Tk potential internal bit-rot issues, I
would strongly encourage you (post-release) to establish some minimum
Tcl/Tk version we support (8.5?) and review all our Tcl/Tk code and
systematically replace Tcl/Tk API calls that were deprecated as of
that version with the recommended replacements.  That's worth
doing in its own right and may have some impact on the memory
management issues I have discovered.

I am bringing up these tk device driver memory management issues because
they are fresh in my mind, but I emphasize again they should only be
tackled post-release.

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); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); 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
__________________________

Attachment: valgrind.out.gz
Description: compressed valgrind report

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to