From: Alan W. I. <ir...@be...> - 2002-07-05 16:31:58
|
I have just been running some tests with valgrind, and there are lots of problems in the plplot core and in drivers with code that allocates memory but which does not free it afterward. In some cases even the pointer to the memory area is lost by the time the example code exits. All this stuff is fairly non-consequential since most users of plplot have large memory at their disposal and these leaks are relatively modest. Nevertheless, it would be nice to get this all cleaned up so we have clean valgrind runs on all our examples for the C front end (the x??c examples), and the psc device. Thus, I am calling for "janitorial" volunteers to work on this with me. It's a perfect part-time project; it shouldn't take that long to remove one memory leak, and that one removal is a worthwhile step in the right direction. Once we have all the x??c examples running valgrind clean with the psc device I intend to expand the project to other front ends and other devices. To give you an idea of the scale of the problem, I append below a typical valgrind run which shows 16 different problems like this for x01c -dev psc. BTW, to get the line numbers listed this way you must configure plplot --with-debug=yes --with-opt=no Also, I have to agree with the tone of prior remarks from Geoffrey and Joao; valgrind is just an awesome tool for figuring out memory management problems if you have access to a Linux x86 box. The --gdb-attach=yes valgrind option below allows you to jump immediately into gdb if your code ever attempts to use uninitialized or freed memory (BTW, from the report below that apparently is not a problem for x01c), and I have already used that option to diagnose and quickly clean up some memory management problems that showed up for the eighth example. For more valgrind information see http://developer.kde.org/~sewardj/. Alan email: ir...@be... phone: 250-727-2902 FAX: 250-721-7715 snail-mail: Dr. Alan W. Irwin Department of Physics and Astronomy, University of Victoria, P.O. Box 3055, Victoria, British Columbia, Canada, V8W 3P6 __________________________ Linux-powered astrophysics __________________________ valgrind --leak-check=yes --show-reachable=yes --gdb-attach=yes --num-callers=20 ./x01c -dev psc -o test.ps ==26486== valgrind-1.0pre2, a memory error detector for x86 GNU/Linux. ==26486== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward. ==26486== Estimated CPU clock rate is 604 MHz ==26486== For more details, rerun with: -v ==26486== Plplot library version: 5.1.0 Opened test.ps ==26486== ==26486== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 1) ==26486== malloc/free: in use at exit: 6730 bytes in 227 blocks. ==26486== malloc/free: 240 allocs, 13 frees, 67950 bytes allocated. ==26486== For counts of detected errors, rerun with: -v ==26486== searching for pointers to 227 not-freed blocks. ==26486== checked 6586072 bytes. ==26486== ==26486== definitely lost: 28 bytes in 2 blocks. ==26486== possibly lost: 0 bytes in 0 blocks. ==26486== still reachable: 6702 bytes in 225 blocks. ==26486== ==26486== 15 bytes in 1 blocks are still reachable in loss record 1 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x4059C39F: (within /lib/libc-2.2.5.so) ==26486== by 0x405BEEFF: (within /lib/libc-2.2.5.so) ==26486== by 0x405BFC1E: (within /lib/libc-2.2.5.so) ==26486== by 0x405BC8A2: (within /lib/libc-2.2.5.so) ==26486== by 0x405BC791: (within /lib/libc-2.2.5.so) ==26486== by 0x402C2FE5: ps_getdate (ps.c:638) ==26486== by 0x402C180E: ps_init (ps.c:178) ==26486== by 0x402C158C: plD_init_psc (ps.c:101) ==26486== by 0x402552C9: plP_init (plcore.c:58) ==26486== by 0x40258653: c_plinit (plcore.c:1165) ==26486== by 0x8048ED2: main (x01c.c:114) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 18 bytes in 1 blocks are still reachable in loss record 2 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x40005A9E: _dl_map_object (in /lib/ld-2.2.5.so) ==26486== by 0x4061F9CA: (within /lib/libc-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x4061FE07: (within /lib/libc-2.2.5.so) ==26486== by 0x40505EE4: (within /lib/libdl-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x405062EF: (within /lib/libdl-2.2.5.so) ==26486== by 0x40505F1F: (within /lib/libdl-2.2.5.so) ==26486== by 0x4025A02F: plLoadDriver (plcore.c:1840) ==26486== by 0x4025937D: plGetDev (plcore.c:1534) ==26486== by 0x40258649: c_plinit (plcore.c:1160) ==26486== by 0x8048ED2: main (x01c.c:114) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 28 bytes in 2 blocks are definitely lost in loss record 3 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x4025F0E8: plstrdup (plctrl.c:1722) ==26486== by 0x40259775: plInitDispatchTable (plcore.c:1643) ==26486== by 0x40258545: pllib_init (plcore.c:1092) ==26486== by 0x40248DD0: plMergeOpts (plargs.c:703) ==26486== by 0x8048E8C: main (x01c.c:101) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 36 bytes in 3 blocks are still reachable in loss record 4 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x405BED70: (within /lib/libc-2.2.5.so) ==26486== by 0x405C0415: (within /lib/libc-2.2.5.so) ==26486== by 0x405BEF2A: (within /lib/libc-2.2.5.so) ==26486== by 0x405BFC1E: (within /lib/libc-2.2.5.so) ==26486== by 0x405BC8A2: (within /lib/libc-2.2.5.so) ==26486== by 0x405BC791: (within /lib/libc-2.2.5.so) ==26486== by 0x402C2FE5: ps_getdate (ps.c:638) ==26486== by 0x402C180E: ps_init (ps.c:178) ==26486== by 0x402C158C: plD_init_psc (ps.c:101) ==26486== by 0x402552C9: plP_init (plcore.c:58) ==26486== by 0x40258653: c_plinit (plcore.c:1165) ==26486== by 0x8048ED2: main (x01c.c:114) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 80 bytes in 1 blocks are still reachable in loss record 5 of 16 ==26486== at 0x4004304F: calloc (vg_clientfuncs.c:221) ==26486== by 0x4000ADED: _dl_check_map_versions (in /lib/ld-2.2.5.so) ==26486== by 0x4061FABE: (within /lib/libc-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x4061FE07: (within /lib/libc-2.2.5.so) ==26486== by 0x40505EE4: (within /lib/libdl-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x405062EF: (within /lib/libdl-2.2.5.so) ==26486== by 0x40505F1F: (within /lib/libdl-2.2.5.so) ==26486== by 0x4025A02F: plLoadDriver (plcore.c:1840) ==26486== by 0x4025937D: plGetDev (plcore.c:1534) ==26486== by 0x40258649: c_plinit (plcore.c:1160) ==26486== by 0x8048ED2: main (x01c.c:114) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 96 bytes in 2 blocks are still reachable in loss record 6 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x4025952A: plInitDispatchTable (plcore.c:1601) ==26486== by 0x40258545: pllib_init (plcore.c:1092) ==26486== by 0x40248DD0: plMergeOpts (plargs.c:703) ==26486== by 0x8048E8C: main (x01c.c:101) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 100 bytes in 1 blocks are still reachable in loss record 7 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x4000925D: _dl_map_object_deps (in /lib/ld-2.2.5.so) ==26486== by 0x4061FA86: (within /lib/libc-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x4061FE07: (within /lib/libc-2.2.5.so) ==26486== by 0x40505EE4: (within /lib/libdl-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x405062EF: (within /lib/libdl-2.2.5.so) ==26486== by 0x40505F1F: (within /lib/libdl-2.2.5.so) ==26486== by 0x4025A02F: plLoadDriver (plcore.c:1840) ==26486== by 0x4025937D: plGetDev (plcore.c:1534) ==26486== by 0x40258649: c_plinit (plcore.c:1160) ==26486== by 0x8048ED2: main (x01c.c:114) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 120 bytes in 1 blocks are still reachable in loss record 8 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x402594FB: plInitDispatchTable (plcore.c:1591) ==26486== by 0x40258545: pllib_init (plcore.c:1092) ==26486== by 0x40248DD0: plMergeOpts (plargs.c:703) ==26486== by 0x8048E8C: main (x01c.c:101) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 146 bytes in 1 blocks are still reachable in loss record 9 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x400430E4: realloc (vg_clientfuncs.c:244) ==26486== by 0x40007E5D: _dl_new_object (in /lib/ld-2.2.5.so) ==26486== by 0x4000443B: _dl_map_object_from_fd (in /lib/ld-2.2.5.so) ==26486== by 0x40005C21: _dl_map_object (in /lib/ld-2.2.5.so) ==26486== by 0x4061F9CA: (within /lib/libc-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x4061FE07: (within /lib/libc-2.2.5.so) ==26486== by 0x40505EE4: (within /lib/libdl-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x405062EF: (within /lib/libdl-2.2.5.so) ==26486== by 0x40505F1F: (within /lib/libdl-2.2.5.so) ==26486== by 0x4025A02F: plLoadDriver (plcore.c:1840) ==26486== by 0x4025937D: plGetDev (plcore.c:1534) ==26486== by 0x40258649: c_plinit (plcore.c:1160) ==26486== by 0x8048ED2: main (x01c.c:114) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 224 bytes in 1 blocks are still reachable in loss record 10 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x402595CC: plInitDispatchTable (plcore.c:1614) ==26486== by 0x40258545: pllib_init (plcore.c:1092) ==26486== by 0x40248DD0: plMergeOpts (plargs.c:703) ==26486== by 0x8048E8C: main (x01c.c:101) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 364 bytes in 1 blocks are still reachable in loss record 11 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x4058A681: (within /lib/libc-2.2.5.so) ==26486== by 0x40247B46: pdf_fopen (pdfutils.c:99) ==26486== by 0x4025E096: plLibOpenPdfstrm (plctrl.c:1193) ==26486== by 0x4025DF8E: plLibOpen (plctrl.c:1160) ==26486== by 0x40259420: plInitDispatchTable (plcore.c:1567) ==26486== by 0x40258545: pllib_init (plcore.c:1092) ==26486== by 0x40248DD0: plMergeOpts (plargs.c:703) ==26486== by 0x8048E8C: main (x01c.c:101) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 454 bytes in 1 blocks are still reachable in loss record 12 of 16 ==26486== at 0x4004304F: calloc (vg_clientfuncs.c:221) ==26486== by 0x40007CAF: _dl_new_object (in /lib/ld-2.2.5.so) ==26486== by 0x4000443B: _dl_map_object_from_fd (in /lib/ld-2.2.5.so) ==26486== by 0x40005C21: _dl_map_object (in /lib/ld-2.2.5.so) ==26486== by 0x4061F9CA: (within /lib/libc-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x4061FE07: (within /lib/libc-2.2.5.so) ==26486== by 0x40505EE4: (within /lib/libdl-2.2.5.so) ==26486== by 0x40009ACB: _dl_catch_error (in /lib/ld-2.2.5.so) ==26486== by 0x405062EF: (within /lib/libdl-2.2.5.so) ==26486== by 0x40505F1F: (within /lib/libdl-2.2.5.so) ==26486== by 0x4025A02F: plLoadDriver (plcore.c:1840) ==26486== by 0x4025937D: plGetDev (plcore.c:1534) ==26486== by 0x40258649: c_plinit (plcore.c:1160) ==26486== by 0x8048ED2: main (x01c.c:114) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 560 bytes in 1 blocks are still reachable in loss record 13 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x402595A9: plInitDispatchTable (plcore.c:1613) ==26486== by 0x40258545: pllib_init (plcore.c:1092) ==26486== by 0x40248DD0: plMergeOpts (plargs.c:703) ==26486== by 0x8048E8C: main (x01c.c:101) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 976 bytes in 1 blocks are still reachable in loss record 14 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x405BFFF8: (within /lib/libc-2.2.5.so) ==26486== by 0x405BEF2A: (within /lib/libc-2.2.5.so) ==26486== by 0x405BFC1E: (within /lib/libc-2.2.5.so) ==26486== by 0x405BC8A2: (within /lib/libc-2.2.5.so) ==26486== by 0x405BC791: (within /lib/libc-2.2.5.so) ==26486== by 0x402C2FE5: ps_getdate (ps.c:638) ==26486== by 0x402C180E: ps_init (ps.c:178) ==26486== by 0x402C158C: plD_init_psc (ps.c:101) ==26486== by 0x402552C9: plP_init (plcore.c:58) ==26486== by 0x40258653: c_plinit (plcore.c:1165) ==26486== by 0x8048ED2: main (x01c.c:114) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 1344 bytes in 28 blocks are still reachable in loss record 15 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x4025974C: plInitDispatchTable (plcore.c:1640) ==26486== by 0x40258545: pllib_init (plcore.c:1092) ==26486== by 0x40248DD0: plMergeOpts (plargs.c:703) ==26486== by 0x8048E8C: main (x01c.c:101) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== 2169 bytes in 181 blocks are still reachable in loss record 16 of 16 ==26486== at 0x40042BDB: malloc (vg_clientfuncs.c:100) ==26486== by 0x4025F0E8: plstrdup (plctrl.c:1722) ==26486== by 0x40259775: plInitDispatchTable (plcore.c:1643) ==26486== by 0x40258545: pllib_init (plcore.c:1092) ==26486== by 0x40248DD0: plMergeOpts (plargs.c:703) ==26486== by 0x8048E8C: main (x01c.c:101) ==26486== by 0x4054214F: (within /lib/libc-2.2.5.so) ==26486== by 0x8048DA1: plMergeOpts (in /home/software/plplot_cvs/HEAD/plplot_working3/tmp/x01c) ==26486== ==26486== LEAK SUMMARY: ==26486== definitely lost: 28 bytes in 2 blocks. ==26486== possibly lost: 0 bytes in 0 blocks. ==26486== still reachable: 6702 bytes in 225 blocks. ==26486== |