Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Tk fonts crash on Fedora

by wulvrine (Friar)
on Nov 28, 2007 at 15:20 UTC ( [id://653551]=perlquestion: print w/replies, xml ) Need Help??

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

Hello fellow monks,

I have been having a problem converting a program that works on RedHat9 over to a Fedora (5,6,7) system. After the 3rd use of a font, I get a seg-fault. I have a small program that shows this exact problem

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Font; use Data::Dumper; printf "The version of Tk is '%s'\n", $Tk::VERSION; printf "The version of Tk::Font is '%s'\n", $Tk::Font::VERSION; make_gui(); MainLoop(); sub make_gui { # Main application window. my $mw = new MainWindow; # Create the font my @fontopts = (-family => 'Times', -size => 12, -weight => 'bold' +); my $font = $mw->fontCreate(@fontopts); my $psubfonts = $mw->font('subfonts', $font); print Data::Dumper->new([$mw->fontActual($font), $psubfonts], [qw()])->Indent(1)->Useqq(1)->Dump; my $phello = sub { print "Hello\n" }; my $fr = $mw->Frame()->pack(); print "Creating button 1...\n"; $fr->Button(-text=>"B1", -command=>$phello,-font=>$font)->pack(); print "Creating button 2...\n"; $fr->Button(-text=>"B2", -command=>$phello,-font=>$font)->pack(); print "Creating button 3...\n"; $fr->Button(-text=>"B3", -command=>$phello, -font=>$font)->pack(); }

When I run this, I get a seg fault while trying to create the third button.
Comment out the last $fr->Button command and a 2 button window is created.
If I remove all -font commands it works fine (keep adding more buttons etc).
(WIERDNESS: exiting out will cause a segmentation fault.. REMOVE fonts altogether and this fault also does not happen).

I searched here and on google, and I haven't found anything of help, so any assistance is appreciated.

Thanks!!

ps. code updated as per suggestion from zentara

s&&VALKYRIE &&& print $_^q|!4 =+;' *|

Replies are listed 'Best First'.
Re: Tk fonts crash on Fedora
by Ray Smith (Beadle) on Nov 28, 2007 at 15:39 UTC
    Interesting. Note for another data point, I ran the program unchanged under Microsoft Windows XP an it presented no problems there.
Re: Tk fonts crash on Fedora
by Tux (Canon) on Nov 28, 2007 at 16:02 UTC

    No problems here (openSUSE 10.3, Linux 2.6.18.8-0.7 x86_64, perl-5.8.8-64all-dor) either, but I admit I use a more recent pTk:

    /tmp 104 > perl test.pl The version of Tk is '804.027501' The version of Tk::Font is '4.004' $VAR1 = "-family"; $VAR2 = "Nimbus Roman No9 L"; $VAR3 = "-size"; $VAR4 = -15; $VAR5 = "-weight"; $VAR6 = "bold"; $VAR7 = "-slant"; $VAR8 = "roman"; $VAR9 = "-underline"; $VAR10 = 0; $VAR11 = "-overstrike"; $VAR12 = 0; $VAR13 = [ [ "Nimbus Roman No9 L", "urw", "Unknown", -1, "/usr/share/fonts/URW/n021004l.pfb" ], [ "Nimbus Roman No9 L", "urw", "Unknown", -1, "/usr/share/fonts/URW/n021003l.pfb" : : [ "Misc Fixed", "Misc", "Unknown", -1, "/usr/share/fonts/misc/10x20.pcf.gz" ] ]; Creating button 1... Creating button 2... Creating button 3...

    Enjoy, Have FUN! H.Merijn
Re: Tk fonts crash on Fedora
by zentara (Archbishop) on Nov 28, 2007 at 16:44 UTC
    One thing I see bad in your code, is that you don't define 'myfont'.
    my $font = $mw->fontCreate(@fontopts); # that should be my $font = $mw->fontCreate('myfont', @fontopts); #otherwise you need to use $font in the -font option $fr->Button(-text=>"B1", -command=>$phello,-font=>$font )->pack(
    Try cleaning that up and see what happens.

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      zentara
      Thanks for pointing that blunder out!
      I've changed it to both "fontCreate('myFont', @fontopts)" and to just using "-font=>$font"
      and unfortunately both still show the seg fault.
      Any other ideas??

      I'm going to update the post with that fix

      s&&VALKYRIE &&& print $_^q|!4 =+;' *|
        Any other ideas??

        I googled for "Fedora fonts" and apparently there are others who have problems too. Maybe try changing the font to something else, like Helvetica or Courier, possibly Times has a problem in your Fedora version?


        I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: Tk fonts crash on Fedora
by shmem (Chancellor) on Nov 29, 2007 at 12:25 UTC
    No problem here on Fedora release 7 (Moonshine). Output:
    The version of Tk is '804.027001' The version of Tk::Font is '4.004' $VAR1 = "-family"; $VAR2 = "Nimbus Roman No9 L"; $VAR3 = "-size"; $VAR4 = -16; $VAR5 = "-weight"; $VAR6 = "bold"; $VAR7 = "-slant"; $VAR8 = "roman"; $VAR9 = "-underline"; $VAR10 = 0; $VAR11 = "-overstrike"; $VAR12 = 0; $VAR13 = [ [ "Nimbus Roman No9 L", "urw", "Unknown" ], [ "Nimbus Roman No9 L", "urw", "Unknown" ], [ "Liberation Serif", "unknown", "Unknown" ], ...more arrays... ]; Creating button 1... Creating button 2... Creating button 3...

    Are you missing a font package? (Hint: urw-fonts ;-)

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      shmem
      Really? Does it still work if you add say 6 buttons?
      I looked and I am running same Tk (804.027) and Font (4.004) with fc6 and fc7.
      I wonder why yours is working at all. I have seen it do three but fail at 4 or 5.

      Also if it was a failed font package, wouldn't it seg fault at the first use? no?
      If I run it with just 2 buttons it loads (with what looks to be right font) and runs ok
      (other than the seg fault when exiting..which I also don't understand).

      Thanks for the help!!

      s&&VALKYRIE &&& print $_^q|!4 =+;' *|
        Yes, it just runs. 6,7...12 buttons, no problem.

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Tk fonts crash on Fedora
by eserte (Deacon) on Nov 29, 2007 at 20:40 UTC
    Any chance to get a backtrace from the core dump?
    gdb perl core bt
      eserte
      I don't know where to look for that core file, there isn't one on the directory in which I ran the script??

      s&&VALKYRIE &&& print $_^q|!4 =+;' *|
        Maybe there is a limit which prevents from creating core dump files. Try ulimit -c unlimited or a similar construct (this depends on your shell) to allow unlimited core dump files for the current shell process.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://653551]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-23 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found