Re: Assertion image->cache != (Cache) ((void *)0)' failed.

Bob Friesenhahn <[email protected]> Sat, 22 Mar 2008 11:43:10 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.bugs
Message-ID <[email protected]>
On Thu, 13 Mar 2008, Micha? Kowalczuk wrote:

> Hello,
> I found a bug in GraphicsMagick. It happened when I tried to scale this jpeg
> file: http://kowalczuk.eu/other/GM-bug.jpg

What is the origin of this JPEG file?  How was it created?

Applications associated with libjpeg believe that this file contains a 
comment of 11822 bytes.  The resulting output image is completely 
white.

> I've done some research and I think that gm improperly finds a comment in this
> file (this image has no comment). Then in function CloneImage() it tries to

Programs depending on libjpeg seem to think that there is a comment. 
Try executing

   djpeg -verbose -pnm -outfile crap.ppm GM-bug.jpg

or

   gm identify -verbose -debug coder,exception GM-bug.jpg

> clone also this found comment. When parsing the comment it finds pattern %#
> and tries to translate it to pixel signature, but since clone_image->cache is
> NULL it fails on assert in AcquireImagePixels().

It is difficult for me to imagine a valid purpose for performing 
pattern replacement on the image comment.  I will investigate the 
reason for this and either fix the pattern replacement code, or 
eliminate it from the execution path.

> But I think that the main problem is that gm is trying to clone the comment
> when there isn't one in the source file. Also, checking existence of cache
> before calling SignatureImage() is also not a bad idea.

It would be necessary to check this before executing any algorithm. 
It is better to fix this problem close to where it originates from.

Bob
======================================
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/