pashanoid has asked for the wisdom of the Perl Monks concerning the following question:

Something strange is happening when I hit a button that calls a exit:

[pasha@pelikan tk]$ perl dial.pl Font info_rus still in cache. Font ticks still in cache. Font bar_rus still in cache. Font logo_rus still in cache. Font dial_rus still in cache. Segmentation fault (core dumped)

The script is too large to post here, so I uploaded it to my site: http://pashanoid.ru/dial.pl

Should I destroy these font objects or something? I don't like programs dumping core... please help! Many thanks!

Replies are listed 'Best First'.
Re: perl tk script dumps core?!
by Anonymous Monk on Jul 08, 2011 at 06:41 UTC

    The script is too large to post here,

    Start deleting lines (functions) until it stops crashing :)

    Should I destroy these font objects or something?

    You could try (fontDelete), but it won't make a difference :) Try Tk-804.029_500, and if the problem persists, report it to the maintainer.

    Also, your program wouldn't too big to post here if you did not embed gifs -- you can use placeholders

    Tk->findINC('demos/images/flagup'), Tk->findINC('demos/images/flagdown'),
      Also, you should try and eliminate Serialport as the thing that is crashing, you could try Devel::Trace to find that out (or insert print statements to see how it gets)

        These lines of code cause the segfault and core dump:

        my $button1 = $mw->Photo(-data => &encoded_but1, -format => 'gif'); my $button2 = $mw->Photo(-data => &encoded_but2, -format => 'gif'); my $button3 = $mw->Photo(-data => &encoded_but_exit1, -format => 'gif' +); my $button4 = $mw->Photo(-data => &encoded_but_exit2, -format => 'gif' +); my $but1 = $c->createImage(40, 400, -image => $button1, -anchor => 'nw +', -tags => ['but1']); $c->bind( $but1, '<Enter>', sub {$c->itemconfigure( $but1, -image => $ +button2); }); $c->bind( $but1, '<Leave>', sub {$c->itemconfigure( $but1, -image => $ +button1); }); $c->bind( $but1, '<ButtonPress>', sub{ &tabbed; } ); my $but2 = $c->createImage(450, 400, -image => $button3, -anchor => 'n +w', -tags => ['but2']); $c->bind( $but2, '<Enter>', sub {$c->itemconfigure( $but2, -image => $ +button4); }); $c->bind( $but2, '<Leave>', sub {$c->itemconfigure( $but2, -image => $ +button3); }); $c->bind( $but2, '<ButtonPress>', sub { &disconnect; $mw->fontDelete('info_rus'); $mw->fontDelete('ticks'); $mw->fo +ntDelete('bar_rus'); $mw->fontDelete('dial_rus'); exit; });