sgriggs
Posts: 3
Joined: Sun Aug 19, 2012 7:38 pm

perl segmentation fault using GD::Graph

Sun Aug 19, 2012 7:44 pm

I'm running raspbian wheezy and when I run this example code it segmentation faults. Any help would be appreciated.

Code: Select all

#!/usr/bin/perl -w
# Change above line to point to your perl binary

use CGI ':standard';
use GD::Graph::bars;
use strict;

# Both the arrays should same number of entries.
my @data = (["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
             "Sep", "Oct", "Nov", "Dec"],
            [23, 5, 2, 20, 11, 33, 7, 31, 77, 18, 65, 52]);

my $mygraph = GD::Graph::bars->new(500, 300);
$mygraph->set(
    x_label     => 'Month',
    y_label     => 'Number of Hits',
    title       => 'Number of Hits in Each Month in 2002',
) or warn $mygraph->error;

my $myimage = $mygraph->plot(\@data) or die $mygraph->error;

print "Content-type: image/png\n\n";
print $myimage->png;

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: perl segmentation fault using GD::Graph

Mon Aug 20, 2012 8:22 am

@sgriggs: I cannot reproduce this:

Code: Select all

pi@raspberrypi ~/raspi_forum $ perl test.pl > test.dat
pi@raspberrypi ~/raspi_forum $ uname -a
Linux raspberrypi 3.1.9+ #272 PREEMPT Tue Aug 7 22:51:44 BST 2012 armv6l GNU/Linux
``test.dat`` contains the expected output.

Code: Select all

while not self.asleep():
    sheep += 1

sgriggs
Posts: 3
Joined: Sun Aug 19, 2012 7:38 pm

Re: perl segmentation fault using GD::Graph

Mon Aug 20, 2012 3:19 pm

This is my uname output.

Code: Select all

Linux raspberrypi 3.2.27+ #6 PREEMPT Sat Aug 18 15:05:48 BST 2012 armv6l GNU/Linux
It seems to differ from yours. If you are using the squeeze image then I can confirm it does work but when I switched to wheezy I now get a segmentation fault.

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: perl segmentation fault using GD::Graph

Mon Aug 20, 2012 3:28 pm

I am using the Raspbian image from the raspberrypi.org download section.

Code: Select all

while not self.asleep():
    sheep += 1

User avatar
jojopi
Posts: 3104
Joined: Tue Oct 11, 2011 8:38 pm

Re: perl segmentation fault using GD::Graph

Mon Aug 20, 2012 4:03 pm

How did you install GD::Graph? It seems fine in 2012-07-15 with version 1.44-6 from "sudo apt-get install libgd-graph-perl".

sgriggs
Posts: 3
Joined: Sun Aug 19, 2012 7:38 pm

Re: perl segmentation fault using GD::Graph

Mon Aug 20, 2012 4:14 pm

Thank you jojopi. You just solved this for me. I used CPAN to install GD::Graph but I took your suggestion and used apt-get to install libgd-graph-perl and now it works. Thank you again for your suggestion and thank you blackjack for your assistance.

Return to “Other programming languages”