Page 1 of 1

Please help: Convert crashes every 1000 images or so

Posted: 2011-06-09T07:35:35-07:00
by jmil
Hi,

I have a python script that is processing 6,240 14-bit TIFs, each one has to be made into 32 new images (8-bit exposure ranges), which are later enfused with Enfuse (also via command line).

Unfortunately, ImageMagick "convert" command crashes every 500-1000 images or so, it just freezes the entire python script. I have to control-C to kill the current convert command, then the script continues to run until the next error.

I am not running out of system memory. However, occasionally I get a convert malloc error when it freezes, but not always:
convert(64216,0x7fff70cdbca0) malloc: *** error for object 0x100b00488: incorrect checksum for freed object - object was probably modified after being freed.

I can re-run the script any number of times to have it create only the ones it failed to make the first time. But that is troublesome because I have to check on it and babysit it every couple hours hit control-C.

What is the fix or a more permanent workaround? Code details are below. It will always freeze right after the "print" statement, activity monitor shows that "convert" command is continuing to run at 80% CPU, but it will stay like that for hours until I control-C it to kill that individual convert command. The image is never created. The next image is created just fine. And then the script continues to run.

many thanks,
jmil


SYSTEM DETAILS:
Version: ImageMagick 6.7.0-0 2011-06-07 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP OpenCL

OS X 10.6.7
Shell processing, from python script.



rangeBottomTemp = 0
rangeTopTemp = 1
for i in range(32):
if (rangeBottomTemp < rangeTopTemp):
rangeTopTemp = rangeBottomTemp + binningRange
print "You have set the linear-stretch range for image \"" + str(i) + "\" to be " + str(rangeBottomTemp) + " and " + str(rangeTopTemp) + ", respectively"
os.system("convert -quiet \"" + file + "\" -level " + str(rangeBottomTemp) + "," + str(rangeTopTemp) + " -depth 8 -colorspace Gray " + newDir + "\"/" + file[:-4] + "/" + file[:-4] + "_UniformBrightness_"+ str(i) + ".tif\" " )
rangeBottomTemp = rangeTopTemp - binningRange / 2

Re: Please help: Convert crashes every 1000 images or so

Posted: 2011-06-09T07:42:02-07:00
by magick
It is difficult to debug this problem remotely. An malloc exception typically implies memory corruption. However, did the memory corruption come from ImageMagick or from the TIFF delegate library. We'll need a stack trace to comment further or a archive with your images and scripts such that we could run it and reproduce the problem providing us with an opportunity to trace the source of the corruption.

Re: Please help: Convert crashes every 1000 images or so

Posted: 2011-06-09T07:48:10-07:00
by jmil
i don't know how to do that, any tips?

the thing is, it is taking one image and making 32 images from that. So the source file is not corrupt, because invariably 31 other images are processed fine.

Also, it is completely random, sometimes it is the first image, sometimes the 14th image, etc.

And it is only every 1000 images or so.

Is there a better way to run imagemagick convert? Should I be spawning each convert command into its own process? Should I be running with a bash script instead of a python script?

Has anyone ever heard of anything like this before? Google doesn't seem to think so, but maybe I'm just typing wrong. hmmm....