"Memory allocation failed" error running convert

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
aksdc
Posts: 4
Joined: 2011-08-30T14:10:05-07:00
Authentication code: 8675308

"Memory allocation failed" error running convert

Post by aksdc »

$ convert MainMR171004.jpg resultImage.jpg
convert: Memory allocation failed `No such file or directory' @ string.c/AcquireStringInfo/173.


Running ImageMagick 6.5.7-8 2010-12-02 Q16 on Ubuntu 10.04.3 (Lucid)

The file is loaded from: http://www.costumes4less.com/Prodimages ... 171004.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: "Memory allocation failed" error running convert

Post by fmw42 »

The file that I download from your link appears to be corrupt. Can you check that it was correctly uploaded and that you can download it and view it. Check also that you can view the original file.
aksdc
Posts: 4
Joined: 2011-08-30T14:10:05-07:00
Authentication code: 8675308

Re: "Memory allocation failed" error running convert

Post by aksdc »

It does seem to be corrupt, and this is the point: being able to handle corrupted images gracefully without crash.
Analogy: if one tries to process text file as jpeg, imagemagick currently detects the problem and issues error message without crashing, thus allowing the client application to recover.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: "Memory allocation failed" error running convert

Post by fmw42 »

see -quiet -regard-warnings at http://www.imagemagick.org/Usage/basics/#controls

I use that to cause an error message to be displayed when there is problem reading an image.

Something like the following:


# test input image
convert -quiet -regard-warnings "$infile" +repage "$tmpA1" ||
errMsg "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"

where $tmpA1 is set to a .mpc format for further use
aksdc
Posts: 4
Joined: 2011-08-30T14:10:05-07:00
Authentication code: 8675308

Re: "Memory allocation failed" error running convert

Post by aksdc »

Fred, Thanks for the prompt response!
I read the link and looked at your suggestion. The -quiet and -regard-warnings options seem to be opposite each other. Also, when I tweak your example to convert this corrupted image, I see both ImageMagick error and custom message from double pipe (did not know about that trick before)

Let me supply more details about my pain so you hopefully could advise further:
I have a java app using ImageMagick through JMagick interface. It converts images of various types to jpeg format. In case of corrupted image, the app is able to read ImageInfo but crashes trying to construct new image based on it. The expected behavior would be throwing some exception, like in the case of wrong format I described before. Unfortunately the application just crashes.
Appreciate any help,
Alex
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: "Memory allocation failed" error running convert

Post by fmw42 »

Sorry, I know little about java or JMagick.

You have a very strange file as I get:


infile="MainMR171004.jpg"
convert -quiet -regard-warnings "$infile" "tmp1.mpc" ||
echo "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"


convert: Memory allocation failed `No such file or directory' @ fatal/string.c/AcquireStringInfo/175.


So IM does not even recognize this as a valid file. I have never seen this kind of test fail like this. Perhaps I have never had any really "bad" files.

It then hangs until I cmd-. (on my Mac) to abort and continue processing and then it spits out my error message.
aksdc
Posts: 4
Joined: 2011-08-30T14:10:05-07:00
Authentication code: 8675308

Re: "Memory allocation failed" error running convert

Post by aksdc »

Hi Fred,
Thanks for trying this pesky file on your system. Looks like it is behaving as badly on Mac. I also tested it on http://www.imagemagick.org/MagickStudio ... Studio.cgi and got Internal Server Error.
This problem can unpredictably affect any application that is using IM to process images that are not under its control, hitting especially hard the ones with 24/7 SLAs.
Who decides if / when it is going to be fixed?
Thanks,
Alex
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: "Memory allocation failed" error running convert

Post by fmw42 »

Magick is the one. But I don't know if this is something that IM can deal with. But that would be his determination.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: "Memory allocation failed" error running convert

Post by magick »

We'll get a patch in the next point release of ImageMagick, 6.7.2-2. Thanks.
Post Reply