I'm getting a segfault in a simple block of perl code that does some
image resizing.  It is an intermittent problem happening fairly
regularly - sometimes the program segfaults every time it is run,
other-times it will run for a dozen or more iterations before
segfaulting.    The segfault seems to be unrelated to the data that
is passed to the program.  One moment I will get a segfault and the
next moment, with the exact same data, I may not.  Below is the perl
code used, imagemagick and perl versions, as well as a 'bt' listing
from gdb.


#!/usr/bin/perl

     use CGI;
     my $req = new CGI;

     use Image::Magick;

     my $method          = $ENV{'REQUEST_METHOD'};
     my $v               = $Image::Magick::VERSION;
     my $v2              = $CGI::VERSION;
     my $fSave           = '/home/httpd/vhosts/islandcomputerteam.com/
subdomains/tideline/httpdocs/articles/test/PotHole1.jpg';
     my $strDebug         = '';

     writeLog("\nSTART with method $method and imagemagick $v cgi
$v2 ... ");
     $strDebug   .= qq[method $method and ImageMagick version $v and
CGI version $v2<br>];

     my $image1  = Image::Magick->new;

     open(IMAGE1, $fSave);
     my $imError = $image1->Read(file=>\*IMAGE1);
     close(IMAGE1);
             if ($imError) { errUser("MAGICK DIED READING $imError
with $strDebug"); }

     my $dx1_small       = 100;
     my $dy1_small       = 100;
     $imError = $image1->Resize(width=>$dx1_small, height=>$dy1_small);
             if ($imError) { errUser("MAGICK DIED RESIZING $imError
with $strDebug"); }

     open(IMAGE2, ">$fSave");
     $imError = $image1->Write(file=>\*IMAGE2, filename=>$fSave);
     close(IMAGE2);
             if ($imError) { errUser("MAGICK DIED WRITING $imError
with $strDebug"); }

     undef $image1;

     writeLog("FINISH");
     errUser("FINISHED OK! <br> $strDebug <br>DONE 15");


sub writeLog {
     my $strWrite = $_[0];
     my $logfile = '/bug.log';
     open  (FILEDATA, ">> $logfile")     || Error('open','log file to
write data');
     flock (FILEDATA, 2)                 || Error ('lock','log file
for writing');
     print FILEDATA "$strWrite";
     close (FILEDATA) || Error('close','log file after updating');
}

sub errUser {
     my $strMsg      = $_[0];
     print "Content-type: text/html\n\n";
     print q[<html><head></head><body>];
     print qq[$strMsg];
     print qq[</body></html>\n\n];
     exit;
}



(gdb) bt
#0  0x001d3bb8 in fflush () from /lib/tls/libc.so.6
#1  0x00df0ec4 in SyncBlob (image=0x8f3f3f8) at magick/blob.c:3212
#2  0x00decf85 in CloseBlob (image=0x8f3f3f8) at magick/blob.c:478
#3  0x00ded195 in DestroyBlob (image=0x8f3f3f8) at magick/blob.c:589
#4  0x00e5599a in DestroyImage (image=0x8f3f3f8) at magick/image.c:1495
#5  0x00d4da5d in XS_Image__Magick_DESTROY (my_perl=0x8ba7008,
cv=0x8d16b1c) at Magick.xs:2983
#6  0x00b8b1a5 in Perl_pp_entersub () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#7  0x00b237bc in Perl_call_sv () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#8  0x00b23423 in Perl_call_sv () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#9  0x00b952a6 in Perl_sv_clear () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#10 0x00b956d4 in Perl_sv_free () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#11 0x00b94d03 in Perl_sv_clear () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#12 0x00b956d4 in Perl_sv_free () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#13 0x00b80e95 in Perl_av_undef () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#14 0x00b95040 in Perl_sv_clear () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#15 0x00b956d4 in Perl_sv_free () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#16 0x00bb1211 in Perl_free_tmps () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#17 0x00b830c8 in Perl_pp_nextstate () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#18 0x00b6e91a in Perl_runops_debug () from /usr/lib/perl5/5.8.0/i386-
linux-thread-multi/CORE/libperl.so
#19 0x00b22a3b in perl_run () from /usr/lib/perl5/5.8.0/i386-linux-
thread-multi/CORE/libperl.so
#20 0x00b226c5 in perl_run () from /usr/lib/perl5/5.8.0/i386-linux-
thread-multi/CORE/libperl.so
#21 0x08049413 in main ()
(gdb)



bash-2.05b$ perl -v
This is perl, v5.8.0 built for i386-linux-thread-multi

bash-2.05b$ convert --version
Version: ImageMagick 6.3.2 02/23/07 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to