Skip Menu |

This queue is for tickets about the SVG-Sparkline CPAN distribution.

Report information
The Basics
Id: 89738
Status: resolved
Priority: 0/
Queue: SVG-Sparkline

People
Owner: cpan.wade [...] anomaly.org
Requestors: pjrlist [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1



Subject: Fwd: SVG-Sparkline-0.36
Date: Thu, 24 Oct 2013 20:41:13 +1000
To: "bug-SVG-Sparkline [...] rt.cpan.org" <bug-SVG-Sparkline [...] rt.cpan.org>
From: Peter Robinson <pjrlist [...] gmail.com>
Hello, I have found the Sparkline module crashes when all values passed are equal to zero. In my case it is valid data and I have put in a work-around to skip generating the Sparkline if everything is zero. I already had statistics-descriptive giving me min, max, avg, etc and just skip the chart if min and max are both zero. It would be useful to have the module exit cleanly somehow, rather than attempting to divide by zero. Details of the error are below: Regards, Peter Robinson In Brisbane, Australia Distribution: SVG-Sparkline-0.36 Perl version: This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x86-multi-thread Binary build 1603 [296746] provided by ActiveState http://www.ActiveState.com Built Mar 13 2013 11:29:21 OS Version Windows 7 Professional Service Pack 1 64 Bit v1.08.00.AF Code used to force the error: use strict; use warnings; use diagnostics; use SVG::Sparkline; my @data = ( 0, 0, 0, 0, 0, 0, 0, 0 ) ; my $sl = SVG::Sparkline->new( Line => { values => \@data } ); Error messages: Show quoted text
>perl CrashSparkline.pl
Illegal division by zero at C:/Perl/site/lib/SVG/Sparkline/Utils.pm line 43 (#1) (F) You tried to divide a number by 0. Either something was wrong in your logic, or you need to put a conditional in to guard against meaningless input. Uncaught exception from user code: Illegal division by zero at C:/Perl/site/lib/SVG/Sparkline/Utils.pm line 43. SVG::Sparkline::Utils::calculate_yscale_and_offset(SVG::Sparkline=HASH(0x5002d4), 0, 0) called at C:/Perl/site/lib/SVG/Sparkline/Line.pm line 28 SVG::Sparkline::Line::make("SVG::Sparkline::Line", SVG::Sparkline=HASH(0x5002d4)) called at C:/Perl/site/lib/SVG/Sparkline.pm line 79 SVG::Sparkline::_make(SVG::Sparkline=HASH(0x5002d4), "Line") called at C:/Perl/site/lib/SVG/Sparkline.pm line 52 SVG::Sparkline::new("SVG::Sparkline", "Line", HASH(0x4ffd24)) called at CrashSparkline.pl line 6
Thanks for the nicely detailed bug report. That was definitely a nasty oversight on my part. I will have this bug corrected today, so it should hit the mirrors today or tomorrow. G. Wade Johnson On Thu Oct 24 06:41:44 2013, pjrlist@gmail.com wrote: Show quoted text
> Hello, > I have found the Sparkline module crashes when all values passed are > equal to zero. In my case it is valid data and I have put in a work- > around to skip generating the Sparkline if everything is zero. I > already had statistics-descriptive giving me min, max, avg, etc and > just skip the chart if min and max are both zero. It would be useful > to have the module exit cleanly somehow, rather than attempting to > divide by zero. > > Details of the error are below: > > Regards, Peter Robinson > In Brisbane, Australia > > > > Distribution: SVG-Sparkline-0.36 > > Perl version: > This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32- > x86-multi-thread > Binary build 1603 [296746] provided by ActiveState > http://www.ActiveState.com > Built Mar 13 2013 11:29:21 > > OS Version > Windows 7 Professional > Service Pack 1 > 64 Bit v1.08.00.AF > > > Code used to force the error: > use strict; > use warnings; > use diagnostics; > use SVG::Sparkline; > my @data = ( 0, 0, 0, 0, 0, 0, 0, 0 ) ; > my $sl = SVG::Sparkline->new( Line => { values => \@data } ); > > > > Error messages: >
> > perl CrashSparkline.pl
> Illegal division by zero at C:/Perl/site/lib/SVG/Sparkline/Utils.pm > line 43 (#1) > (F) You tried to divide a number by 0. Either something was wrong > in > your logic, or you need to put a conditional in to guard against > meaningless input. > > Uncaught exception from user code: > Illegal division by zero at > C:/Perl/site/lib/SVG/Sparkline/Utils.pm line 43. > SVG::Sparkline::Utils::calculate_yscale_and_offset(SVG::Sparkline=HASH(0x5002d4), > 0, 0) called at C:/Perl/site/lib/SVG/Sparkline/Line.pm line 28 > SVG::Sparkline::Line::make("SVG::Sparkline::Line", > SVG::Sparkline=HASH(0x5002d4)) called at > C:/Perl/site/lib/SVG/Sparkline.pm line 79 > SVG::Sparkline::_make(SVG::Sparkline=HASH(0x5002d4), "Line") > called at C:/Perl/site/lib/SVG/Sparkline.pm line 52 > SVG::Sparkline::new("SVG::Sparkline", "Line", HASH(0x4ffd24)) > called at CrashSparkline.pl line 6
The code now does something reasonable if all of the data is 0. Verified for Line, Area, Bar, and Whisker Sparklines.
Subject: Re: [rt.cpan.org #89738] Fwd: SVG-Sparkline-0.36
Date: Fri, 25 Oct 2013 09:21:06 +1000
To: "bug-SVG-Sparkline [...] rt.cpan.org" <bug-SVG-Sparkline [...] rt.cpan.org>
From: Peter Robinson <pjrlist [...] gmail.com>
Hi Wade, that was quick, thanks very much. I'll test it out when it gets to me. pjr Sent from my iPhone so please excuse any terse grammar or bad speeling. Peter Robinson In Brisbane, Australia On 24/10/2013, at 23:54, "G. Wade Johnson via RT" <bug-SVG-Sparkline@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=89738 > > > Thanks for the nicely detailed bug report. > > That was definitely a nasty oversight on my part. I will have this bug corrected today, so it should hit the mirrors today or tomorrow. > > G. Wade Johnson > > On Thu Oct 24 06:41:44 2013, pjrlist@gmail.com wrote:
>> Hello, >> I have found the Sparkline module crashes when all values passed are >> equal to zero. In my case it is valid data and I have put in a work- >> around to skip generating the Sparkline if everything is zero. I >> already had statistics-descriptive giving me min, max, avg, etc and >> just skip the chart if min and max are both zero. It would be useful >> to have the module exit cleanly somehow, rather than attempting to >> divide by zero. >> >> Details of the error are below: >> >> Regards, Peter Robinson >> In Brisbane, Australia >> >> >> >> Distribution: SVG-Sparkline-0.36 >> >> Perl version: >> This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32- >> x86-multi-thread >> Binary build 1603 [296746] provided by ActiveState >> http://www.ActiveState.com >> Built Mar 13 2013 11:29:21 >> >> OS Version >> Windows 7 Professional >> Service Pack 1 >> 64 Bit v1.08.00.AF >> >> >> Code used to force the error: >> use strict; >> use warnings; >> use diagnostics; >> use SVG::Sparkline; >> my @data = ( 0, 0, 0, 0, 0, 0, 0, 0 ) ; >> my $sl = SVG::Sparkline->new( Line => { values => \@data } ); >> >> >> >> Error messages: >>
>>> perl CrashSparkline.pl
>> Illegal division by zero at C:/Perl/site/lib/SVG/Sparkline/Utils.pm >> line 43 (#1) >> (F) You tried to divide a number by 0. Either something was wrong >> in >> your logic, or you need to put a conditional in to guard against >> meaningless input. >> >> Uncaught exception from user code: >> Illegal division by zero at >> C:/Perl/site/lib/SVG/Sparkline/Utils.pm line 43. >> SVG::Sparkline::Utils::calculate_yscale_and_offset(SVG::Sparkline=HASH(0x5002d4), >> 0, 0) called at C:/Perl/site/lib/SVG/Sparkline/Line.pm line 28 >> SVG::Sparkline::Line::make("SVG::Sparkline::Line", >> SVG::Sparkline=HASH(0x5002d4)) called at >> C:/Perl/site/lib/SVG/Sparkline.pm line 79 >> SVG::Sparkline::_make(SVG::Sparkline=HASH(0x5002d4), "Line") >> called at C:/Perl/site/lib/SVG/Sparkline.pm line 52 >> SVG::Sparkline::new("SVG::Sparkline", "Line", HASH(0x4ffd24)) >> called at CrashSparkline.pl line 6
> > >