From: Alan W. I. <ir...@be...> - 2004-01-20 03:54:18
|
I have committed to cvs HEAD some changes to tighten memory management of the C examples and also one necessary core change. With these changes C examples 1-21 (excluding the interactive examples 14, 17, and 20) are now absolutely valgrind clean when the psc device is used. Although interactive driver memory management issues obfuscate the results (see below), I have also checked the C code of examples 14, 17, and 21, and I don't believe there are any remaining specific memory management problems in those examples. To eliminate uninitialized memory issues for example 21 that were found by valgrind, I had to make a logic change to src/plot3d.c to eliminate the possibility of plotting a contour when there were no points in the contour. This change also eliminated the same unintialized memory error for examples/c++/x21.cc/ I also did limited testing of -dev ps (as opposed to -dev psc), -dev png and -dev jpeg with valgrind, and all seems absolutely valgrind clean for those devices. I suggest these examples/c changes and the change to src/plot3d.c should be in the next release if Rafael ultimately decides to include all the memory management fixups in the release. Now on to the next topic;memory management problems for -dev xwin, -dev tk, and -dev ntk. The valgrind results for these interactive devices typically show lots of alloced blocks of memory that have not been freed at exit. This might be caused by my rather old versions of the X and Tk libraries not being valgrind clean or it may be that our drivers do not properly close those libraries. For now, I have given up on tracking down this problem so unless somebody else steps forward who has access to more modern X and Tk libraries, the memory management problems for our interactive devices will definitely be a post-release issue. valgrind did turn up one major invalid file descriptor error with example 14 (which must be run with -dev tk). That example exits prematurely with the following error: valgrind ./x14c -dev tk ==14506== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux. ==14506== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward. ==14506== Using valgrind-20030725, a program supervision framework for x86-linux. ==14506== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward. ==14506== Estimated CPU clock rate is 604 MHz ==14506== For more details, rerun with: -v ==14506== Demo of multiple output streams via the tk driver. Running with the second window as slave. Badly formatted packet, numRead = 8 ==14506== Warning: invalid file descriptor 6 in syscall write() Packet send failed: pl_PacketSend -- error writing to fifo: bad file number TCL command "plclient_link_end" failed: no application named "plclient_1" ==14506== discard syms in /home/software/plplot_cvs/install_location_alternative/lib/plplot5.2.1.rc1.5.3.0/driversd/tk.so due to munmap() Program aborted ==14506== ==14506== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==14506== malloc/free: in use at exit: 200338 bytes in 2983 blocks. ==14506== malloc/free: 38847 allocs, 35864 frees, 3180282 bytes allocated. ==14506== For a detailed leak analysis, rerun with: --leak-check=yes ==14506== For counts of detected errors, rerun with: -v This error occurs just after the initial plot is done in the first window and the plotting is just starting in the second window. Without valgrind, the example seems to work fine, but clearly there is some sort of memory problem or error buried deep in the tk driver. If I recall correctly, we have had name issues before with the tk driver when the window name contained odd characters (such as "_"in this case, but I believe it was "/" before), but I have forgotten what was done to sort that out. Maurice, would it be possible for you to quickly replicate that name handling fix (if that truly is the problem) again for the underscore case? If this fix takes more than minimal effort, then dealing with it post-release is fine as well. Alan __________________________ Alan W. Irwin email: ir...@be... phone: 250-727-2902 Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the PLplot scientific plotting software package (plplot.org), the Yorick front-end to PLplot (yplot.sf.net), the Loads of Linux Links project (loll.sf.net), and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ |