Subject: | configure() / cget() free unref scalar |
Date: | Fri, 15 Jul 2011 09:45:29 +1000 |
To: | bug-Tk [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
With recent debian i386 packaged perl-tk 804.029 and perl 5.12.4, the
program foo.pl below gets a warning
Attempt to free unreferenced scalar: SV 0x942b018, Perl interpreter: 0x9183008 at /usr/lib/perl5/Tk/MainWindow.pm line 166.
A backtrace suggests it's somewhere in global destruction,
#0 0x080c4e90 in Perl_warner ()
#1 0x080e9de0 in Perl_sv_free ()
#2 0xb7b1c7c4 in LangFreeArg () from /usr/lib/perl5/auto/Tk/Tk.so
#3 0xb7b655c6 in Tk_FreeOptions () from /usr/lib/perl5/auto/Tk/Tk.so
#4 0xb7b5705b in ?? () from /usr/lib/perl5/auto/Tk/Tk.so
#5 0xb7b4d8af in ?? () from /usr/lib/perl5/auto/Tk/Tk.so
#6 0xb7b269d2 in Tcl_EventuallyFree () from /usr/lib/perl5/auto/Tk/Tk.so
#7 0xb7b4ec78 in TkDeleteAllImages () from /usr/lib/perl5/auto/Tk/Tk.so
#8 0xb7b8d093 in Tk_DestroyWindow () from /usr/lib/perl5/auto/Tk/Tk.so
#9 0xb7b3ad74 in Tk_DestroyObjCmd () from /usr/lib/perl5/auto/Tk/Tk.so
#10 0xb7b15a1d in Call_Tk () from /usr/lib/perl5/auto/Tk/Tk.so
#11 0xb7b16781 in ?? () from /usr/lib/perl5/auto/Tk/Tk.so
#12 0x080e3c53 in Perl_pp_entersub ()
#13 0x080db222 in Perl_runops_standard ()
#14 0x0807b6dd in Perl_call_sv ()
#15 0x0807bdb2 in Perl_call_list ()
#16 0x0807d844 in perl_destruct ()
#17 0x0806576b in main ()
I'm not sure if setting -format this way is supposed to be allowed, but
it probably should have it's ref counts right even if not.
#!/usr/bin/perl -w
use strict;
use Tk;
print Tk->VERSION,"\n";
my $mw = MainWindow->new;
my $photo = $mw->Photo (-width => 16, -height => 16);
print "call configure ...\n";
$photo->configure (-format => 'xpm');
print "call cget ...\n";
$photo->cget ('-format');
print "done\n";
exit 0;