We have an old Perl script that generates a PNG graphic file to show a line-chart in an internal web page. We use that Perl script as a CGI in an Apache web server. It works fine for many years. Recently we want to move the Apache web server from a Windows 7 computer to a Windows 10 computer. And the problem starts. The Perl script cannot use Chart::Lines program module to generate the graphic file. Somehow when I convert the Perl script from a CGI into a plain Perl script and run in a command line, it works fine.
I have tracked down the problem to a line in C:\Strawberry\perl\site\lib\Chart\Base.pm:
sub _draw_right_legend {
.
.
# draw the point
$self->{'gd_obj'}->line(int(($x3+$x2)/2), $y2, int(($x3+$x2)/2), $y2, gdBrushed);
.
.
}
Seem like the use of "gdBrushed" can trigger the problem when the Perl script is running as a CGI. The program will terminate itself right at that line. Unfortunately, when I check the log file in Apache web server, I don't see anything. As mentioned above, the plain-version of the Perl script works fine in command line. This means I cannot see any error message.
If I replace "gdBrushed" with "$color", the CGI script won't crash. But the point that the statement is supposed to draw doesn't appear in the graphic file. ($color is defined inside the same sub routine, and it is used to draw a line). This means this is really not a solution.
For now, I get around this problem by commenting out that line and skip drawing that "point". But I would like to find a better solution.
Please note that when I tried to install GD.pm and Chart::Lines to Perl, the normal process failed to install (because the installation program cannot find GD.pm or Chart::Lines in CPAN any more). I ended up using the brutal force approach to copy the entire Perl program folder from a "known good" Apache web server (Windows 7) to the new server (Windows 10). This may have to do with this problem. But everything else that I use in Chart::Lines is working, except for drawing that "point".
UPDATE 1: Fixed the problem with installation of GD and Chart. Unfortunately this doesn't fix the problem mentioned in this post. The Chart program still crashes when it tries to draw points. I find the error message in error.log in Apache web server:
Insecure dependency in eval while running with -T switch at C:/Strawberry/perl/site/lib/GD.pm line 87.
The statement in GD.pm that triggers the error is:
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function. If a constant is not found then control is passed
# to the AUTOLOAD in AutoLoader.
my($constname);
($constname = $AUTOLOAD) =~ s/.*:://;
undef $!;
my $val = constant($constname);
if ($! != 0) {
if ($! =~ /Invalid/) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
}
else {
my($pack,$file,$line) = caller;
die "Your vendor has not defined GD macro $pack\:\:$constname, used at $file line $line $!.\n";
}
}
eval "sub $AUTOLOAD { $val }"; <-- This triggers the error
goto &$AUTOLOAD;
}
Seem like the problem may have to do with my program using gdBrushed constant. And somehow using that constant triggers this error in GD.pm. And I don't know why.
UPDATE 2: I find that when the error happens, $AUTOLOAD has "GD::gdBrushed" in it. This means this error is likely related to the use of that constant.