Daniel J Sebald <daniel.sebald@...> writes:
>Well, I've got to hand it to valgrind. It found an uninitialized
>variable in the image demo...
Thanks for reminding us about valgrind.
To extend coverage to more terminals, I modified demo/webify like this
open(GNUPLOT, "|valgrind --leak-check=full --log-file=$ARGV[0] ../src/gnuplot") or die "can't find gnuplot";
my $png="png";
if ($#ARGV>0) {$png=$ARGV[1];}
print GNUPLOT "set term $png\n";
print GNUPLOT "set output \"$ARGV[0].$plot.$png\"\n";
so I could call it like this
for x in *.dem; do ./webify.pl `echo $x|sed 's/.dem//'` postscript; done
This leakage turned up every time:
==17498== 156 (36 direct, 120 indirect) bytes in 1 blocks are
definitely lost in loss record 5 of 9
==17498== at 0x1B90459D: malloc (vg_replace_malloc.c:130)
==17498== by 0x1BC6C179: (within /lib/tls/libc-2.3.5.so)
==17498== by 0x1BC6C7C1: __nss_database_lookup (in /lib/tls/libc-2.3.5.so)
==17498== by 0x1B90F139: ???
==17498== by 0x1B9108F4: ???
==17498== by 0x1BC1A0B9: getpwnam_r (in /lib/tls/libc-2.3.5.so)
==17498== by 0x1BC19B41: getpwnam (in /lib/tls/libc-2.3.5.so)
==17498== by 0x80FA84A: getusername (util.c:1143)
==17498== by 0x80DD313: PS_common_init (post.trm:2278)
==17498== by 0x80DD841: PS_init (post.trm:2403)
==17498== by 0x80B62B9: term_init (term.c:531)
==17498== by 0x806E993: do_plot (graphics.c:1301)
getpwman returns a pointer to a struct. Apparently this
implementation allocates space for the struct from the heap. However,
we can't just free it because the man page says the struct may be in a
static area. We could use getpwnam_r instead, if it is available.
Possibly another configuration test?
This one:
==17774== 98 bytes in 2 blocks are definitely lost in loss record 2 of 8
==17774== at 0x1B90459D: malloc (vg_replace_malloc.c:130)
==17774== by 0x804A9CC: gp_alloc (alloc.c:268)
==17774== by 0x80DC8C3: PS_options (post.trm:1427)
==17774== by 0x80A7B13: set_terminal (set.c:3275)
==17774== by 0x8051E88: command (command.c:539)
==17774== by 0x8051938: do_line (command.c:391)
==17774== by 0x8051863: com_line (command.c:342)
==17774== by 0x808E8D8: main (plot.c:639)
show that this allocation in post.trm leaks memory:
ps_fontfile_char = gp_alloc (totlength+1,"ps_fontfile_char");
- Jim Van Zandt
|