Segmentation faults with Perl/Tk

<[email protected]> Thu, 2 Aug 2007 17:58:36 +0800
Newsgroups gmane.comp.lang.perl.tk
Message-ID <CA51DF75AEDD5F439DC58E2383F6CE8C01ED305F@sinse303.ap.infineon.com>
Hello All,

This problem has been discussed in past.  I could see it in the bulletin
board of Perl Tk
http://groups.google.com/group/comp.lang.perl.tk/browse_thread/thread/35
58a8fd6a058721/9476da23af60b648?#9476da23af60b648

I took the examples from one of these discussions, made slight
modification. Sample script is given at the bottom of the mail
All test are on same platform : 5.8 Generic_117350-46 sun4u sparc
SUNW,Sun-Fire-V440

*	Perl Version : v5.8.8
Tk Version : 804.0275
You would have click OK on the button some number of times. I was able
to reproduce the problem 100% of the time.
I removed MainLoop from sub button1 then the code crashed much faster. I
cannot generalize this statement, but this was my observation.

*	I also tried with 
Perl Version : v5.8.7
Tk version : 804.027
This crashes as well

*	Perl Version : v5.8.5
Tk version : 804.027
This crashes as well

*	Perl Version   : v5.8.4
Tk Version : 804.027
This crashes as well

*	Perl Version : v5.6.1
Tk Version : 800.023
Tried five six times up to 200 clicks, no problems at all. Does Not
crash

*	Perl Version : 5.005_03
Tk Version :800.015
Tried five six times up to 200 clicks no problems at all. Does Not crash

Thanks and Regards
Amit



############Sample Script###############
use Tk;
my $var = 0;
$w1 = new MainWindow;
$w1->Label(-text=>"Click Button1, then click the Button2 which 
appears.\nRepeat this two or three times.")->pack;
$w1->Entry(-textvariable => \$var )->pack;
$w1->Button(-text=>'Button1',-command=>\&button1)->pack;
MainLoop;

sub button1
{
$w2 = new MainWindow; 
$w2->Label(-text=>"When you click Button2, \nthis window will be
destroyed \nand a Checkbutton will be created in the first
window.")->pack;
$w2->Button(-text=>'Button2',-command=>\&button2)->pack; 
MainLoop;
}

sub button2
{
$w2->destroy;
#^^^^^^^  This destroy is the key to the core dump.
# If this destroy is at the end of this function, all is well.
#$f1->Checkbutton(-text=>"Check")->pack; 
$var++;
}

--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk