[Israel.pm] Perl 5.8.6 Tk 8.4 run-time crash bug (crossposted to comp.lang.perl.tk)

Felix Liberman felix.liberman at gmail.com
Wed Mar 23 08:01:15 PST 2005

Hi All,
I've discovered interesting bug - my Perl/Tk application
(see snippet below) crashes with nasty message:
=============== (example of M$ Win crash message) ==================
This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.
======================= (end example) ==============================
Any comments?

#!/usr/bin/perl -w

# This is my demo for Perl 5.8.6 Tk 8.4 run-time crash bug:
# When adding item to HList widget with method "add"
# and any of following parameters: -at/-before/-after
# the application crashes (win/linux)
# The same application work fine on Perl 5.6.1 Tk 8.0

use strict;
use Tk;
use Tk::Button;
use Tk::HList;

my $mw=MainWindow->new(-title=>'Perl 5.8.6 Tk 8.4 bug demo');

my $first = 'mw.first';

my $tf = $mw -> HList (-itemtype=>'text' )
  -> pack(-anchor=>'nw', -pady=>5, -side=>'top', -padx=>5);
foreach my $option(qw/-before -after -at/)
  my @where = ($option=>($option eq '-at')?1:$first);

  $mw -> Button ( -command=>[\&Magic,'mw.second_'.time()=>@where],
-text=>"Magic$option" )
   -> pack(-pady=>5, -side=>'left', -padx=>5);


$mw -> Button ( -command=>sub {exit}, -text=>'Dismiss' )
  -> pack(-pady=>5, -side=>'left', -padx=>5);


#===vptk end===< DO NOT CODE ABOVE THIS LINE >===

sub Magic
  my ($id, at where) = @_;
  print "Magic: id=<$id> insert=<@where>\n";
  $tf->add($id, at where,-text=>$id,-data=>$id); 

More information about the Perl mailing list