Few Data Points:
1. I tried to step through the code to find the operation which causes the memory corruption and believe that it is in the SyncAuthenticPixels op (called from SampleImage). I might be wrong here but have added this information in case it helps in debugging this issue further.
2. The crash does not happen will all animated GIF's
3. Crash does not happen when the dimensions are modified to a different values say 40x40 as opposed to to 10x15 (as in the script)
4. I tried the convert routine for a similar operation and it worked fine -
convert ./animation.gif -thumbnail 15x10 ./an-im.jpg
ImageMagick:
Version 6.5.1-10
OS - FreeBSD-6.4.10 amd64
Backtrace:
Program received signal SIGBUS, Bus error.
0x0000000800e401e7 in GetImageListLength (images=0xd0d038381d1d) at magick/list.c:613
613 images=images->previous;
(gdb) bt
#0 0x0000000800e401e7 in GetImageListLength (images=0xd0d038381d1d) at magick/list.c:613
#1 0x0000000800e8858b in ThumbnailImage (image=0x724000, columns=140737488325536, rows=8204288, exception=0x6c9280) at magick/resize.c:2933
#2 0x0000000800c69279 in XS_Image__Magick_Mogrify (cv=0xd0d038381d1d) at Magick.xs:8694
#3 0x000000000046125a in Perl_pp_entersub ()
#4 0x000000000045a88e in Perl_runops_standard ()
#5 0x0000000000418000 in perl_run ()
#6 0x0000000000417ccc in perl_run ()
#7 0x0000000000415484 in main ()
Snippet of code which causes the crash:
Code: Select all
use Image::Magick;
use strict;
use warnings;
sub thumbnail_imagemagick
{
my $content = shift;
my $data_ref = shift;
my $width = 15;
my $height = 10;
my $image = Image::Magick->new();
$image->BlobToImage($content);
$image->Thumbnail("${width}x${height}");
$image->Set(magick => 'JPG');
$image->Set(quality => 70);
$$data_ref = $image->ImageToBlob();
return 0;
}
my $dataOut;
my $content;
my $imageFile = "./animation.gif";
open FP,"$imageFile" or die "Unable to open $imageFile";
binmode(FP);
my $n=0;
my $data;
while (($n = read FP, $data, 4) != 0) {
$content .= $data;
}
close(FP);
thumbnail_imagemagick($content,\$dataOut);
Download the animation from this link -
http://www.bigoo.ws/code/preview/229489.htm