Intermittent colormap error when using identify on PNGs
Posted: 2010-06-02T15:39:09-07:00
Hey guys. We're running into a problem with identify under ImageMagick 6.6.2-0 and 6.6.2-1, but not under 6.6.1-10. We're running on OS X.
On some PNG files the identify command will intermittently give an error. Here's the command we run:
Here's the error we sometimes get (about 39% of the time):
When the command fails with the above error the exit code is 1. I've uploaded a file which produces the error at http://i.imgur.com/L7d2p.png.
I ran 1000 trials and 607 times the command worked fine and 393 times the command failed.
We diffed the released code between 6.6.1-10 and 6.6.2-1. We noticed some changes from long to ssize_t that seemed suspicious (they occurred in the method getting the error), near line 3906 of image.c. I am not 100% sure that's the problem, just noticed it while hunting around for a probable cause. Here's the relevant diff portion I am referring to:
We noticed in the ChangeLog that a similar bug was fixed on May 8th. I am not sure if this represents a regression or not:
Below is all of my possibly relevant system information I could think of:
Versions Tried
6.6.1-10: bug not present
6.6.2-0: buggy
6.6.2-1: buggy
System Specifications
Model: 27" iMac (iMac11,1)
OS: Mac OS X 10.6.3
Processor: 2.8 GHz Intel Core i7 (4 cores)
Memory: 4GB 1067 MHz DDR3
Options Given to ./configure
We printed out the native sizes of long, Int, and ssize_t on our system:
The program we used to compute the type sizes is as follows:
On some PNG files the identify command will intermittently give an error. Here's the command we run:
Code: Select all
identify -format "%wx%h" path/to/image/file.png
Code: Select all
identify: invalid colormap index <filename> @ error/image.c/SyncImage/3906
I ran 1000 trials and 607 times the command worked fine and 393 times the command failed.
We diffed the released code between 6.6.1-10 and 6.6.2-1. We noticed some changes from long to ssize_t that seemed suspicious (they occurred in the method getting the error), near line 3906 of image.c. I am not 100% sure that's the problem, just noticed it while hunting around for a probable cause. Here's the relevant diff portion I am referring to:
Code: Select all
@@ -3865,7 +3871,7 @@
register IndexPacket
*restrict indexes;
- register long
+ register ssize_t
x;
register PixelPacket
@@ -3880,11 +3886,11 @@
continue;
}
indexes=GetCacheViewAuthenticIndexQueue(image_view);
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- index=PushColormapIndex(image,(unsigned long) indexes[x],
+ index=PushColormapIndex(image,(size_t) indexes[x],
&range_exception);
- pixel=image->colormap[(long) index];
+ pixel=image->colormap[(ssize_t) index];
q->red=pixel.red;
q->green=pixel.green;
q->blue=pixel.blue;
Code: Select all
2010-05-08 6.6.1-7 Cristy <quetzlzacatenango@image...>
* Fix improper 'invalid colormap index' PNG bug.
Versions Tried
6.6.1-10: bug not present
6.6.2-0: buggy
6.6.2-1: buggy
System Specifications
Model: 27" iMac (iMac11,1)
OS: Mac OS X 10.6.3
Processor: 2.8 GHz Intel Core i7 (4 cores)
Memory: 4GB 1067 MHz DDR3
Code: Select all
$ uname -a
Darwin turkleton.local 10.3.0 Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu-1504.3.12~1/RELEASE_I386 i386
Code: Select all
$ brew info imagemagick
imagemagick 6.6.2-1
Code: Select all
$ file $(which identify)
/usr/local/bin/identify: Mach-O 64-bit executable x86_64
Code: Select all
$ identify --version
Version: ImageMagick 6.6.2-1 2010-06-02 Q16 http://www.imagemagick.org
Code: Select all
./configure --disable-osx-universal-binary --without-perl --prefix=/usr/local/Cellar/imagemagick/6.6.2-1 --disable-dependency-tracking --enable-shared --disable-static --with-modules --without-magick-plus-plus --without-gslib --with-gs-font-dir=/usr/local/share/ghostscript/fonts
Code: Select all
Long: 8
Int: 4
ssize_t: 8
Code: Select all
/*
*
* $ gcc -Wall -O0 sizes.c -o sizes
* $ ./sizes
* Long: 8
* Int: 4
* ssize_t: 8
*
*/
#include <stdio.h>
#include <unistd.h>
int main() {
printf("Long: %lu\n", sizeof(long));
printf("Int: %lu\n", sizeof(int));
printf("ssize_t: %lu\n", sizeof(ssize_t));
return 0;
}