Skip Menu |

This queue is for tickets about the GDGraph CPAN distribution.

Maintainer(s)' notes

There are plenty of good ideas of what people can do published here on the queue. Turning a patch from the tracker into a pull request is not one of them. In order to get maintainers' attention way more quickier, PR should have at least a sample included. We know it's hard to test images generating software, but it doesn't mean we can not test numbers produced by intermediate algorithms used to generate these images, so either a test or a sample.

Report information
The Basics
Id: 5282
Status: resolved
Priority: 0/
Queue: GDGraph

People
Owner: bwarfield [...] cpan.org
Requestors: geofft [...] remasys.com
imush [...] mail.ru
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.43
Fixed in: 1.4305



Subject: [PATCH] Infinite loop in GD::Graph::axestype::_best_ends
Distribution: GDGraph 1.43 File: axestype.pm (revision 1.44) Description: When the min and max values for the y-axis are both negative, halving the minimum and increasing the maximum by 50% results in a minimum greater than the maximum, giving a negative range. This leads to an infinite loop in the sub _best_ends at the following line: 1651 while ($s > $range) { $s /= 10 } as $s is never going to become negative, just closer and closer to zero. The patch below resolves this issue. --- axestype.pm.orig 2003-12-09 17:06:53.000000000 +1100 +++ axestype.pm 2004-02-11 15:42:07.000000000 +1100 @@ -1622,15 +1622,15 @@ my ($best_min, $best_max, $best_num) = ($min, $max, 1); + # Check that min and max are not the same, and not 0 + ($min, $max) = ($min != 0) ? ($min * 0.5, $min * 1.5) : (-1,1) + if ($max == $min); + # mgjv - Sometimes, for odd values, and only one data set, this will be # necessary _after_ the previous step, not before. Data sets of one # long with negative values were causing infinite loops later on. ($min, $max) = ($max, $min) if ($min > $max); - # Check that min and max are not the same, and not 0 - ($min, $max) = ($min != 0) ? ($min * 0.5, $min * 1.5) : (-1,1) - if ($max == $min); - my @n = ref($n_ref) ? @$n_ref : $n_ref; if (@n <= 0)
Subject: hang in axestype.pm when the y-range is a single negative value point
To reproduce: #!/usr/bin/perl -w use GD::Graph::lines; my $g = GD::Graph::lines->new(1200, 300); my $data = [ [ '1', '2', '3', '4'], [ -1, -1, -1, -1 ] ]; print $g->plot($data)->png; The following code in axestype.pm (sub _best_ends) seems to bear the blame: ... # mgjv - Sometimes, for odd values, and only one data set, this will be # necessary _after_ the previous step, not before. Data sets of one # long with negative values were causing infinite loops later on. ($min, $max) = ($max, $min) if ($min > $max); # Check that min and max are not the same, and not 0 ($min, $max) = ($min) ? ($min * 0.5, $min * 1.5) : (-1,1) if ($max == $min); ... This fails when $min==$max and they are negative, because later on ... my $range = $max - $min; # create array of interval sizes my $s = 1; while ($s < $range) { $s *= 10 } while ($s > $range) { $s /= 10 } #### <<<< we are stuck here ... My fix for this is to do the artificial range widening first, and then swap if necessary: ... # Do this first if we have a constant graph ($min, $max) = ($min) ? ($min * 0.5, $min * 1.5) : (-1,1) if ($max == $min); # Swap if we ended up with inverted (min, max) ($min, $max) = ($max, $min) if ($min > $max); ...
From: imush [...] mail.ru
Sorry, if my marking this 'critical' sounds like yelling in your face. I dod not mean that and cannot find how to downgrade it now. But the bug did cause my process to hang, so it was critical to me.
As far as I can tell, this bug is not present in the current version (1.4308), the lines you mention having been changed (your test script breaks for me under 1.43, but not 1.4308). Upgrading should solve your problem. If you do actually have 1.4308 installed, please check to make sure that it's being used by the code that produces this error--this bug should be fixed since 1.4305. On Fri Mar 30 12:59:50 2007, imush wrote: Show quoted text
> Sorry, if my marking this 'critical' sounds like yelling in your face. I > dod not mean that and cannot find how to downgrade it now. But the bug > did cause my process to hang, so it was critical to me.