Page 1 of 1

policy.xml time limit not working as expected

Posted: 2015-07-21T15:33:07-07:00
by jkortegard
Hi,

I have a troublesome vector EPS file that spins up Ghostscript at 100% CPU but seems to never complete a command, whether it's `identify` or `convert` or something in a PerlMagick script. I have other vector EPS files that work fine, so it's definitely something about the EPS itself and not Ghostscript or ImageMagick in general.

I've been trying to set ImageMagick resource limits in the policy.xml file to keep the ImageMagick process from hanging for so long, but it's not timing out. Here's my time resource entry in policy.xml:

Code: Select all

<!-- policy.xml -->
<policymap>
    <policy domain="resource" name="time" value="30"/>
</policymap>
I can confirm with `identify -list resource` that ImageMagick sees the change to the time resource, however when I run identify on the same EPS file it still hangs, rather than timing out.

Is this because it's an EPS file and ImageMagick has delegated the job to Ghostscript? Is there something else I should be doing regarding the policy settings to get the timeout I want?

When I run `identify -debug All snail.eps` it stalls here:

Code: Select all

...
2015-07-21T15:17:42-07:00 0:00.000 0.000u 6.9.1 Resource identify[28115]: resource.c/AcquireUniqueFileResource/550/Resource
  Acquire /var/tmp/magick-28115-Bk3VxNGPXIL
2015-07-21T15:17:42-07:00 0:00.000 0.000u 6.9.1 Resource identify[28115]: resource.c/RelinquishUniqueFileResource/1039/Resource
  Relinquish /var/tmp/magick-28115-Bk3VxNGPXIL
2015-07-21T15:17:42-07:00 0:00.000 0.000u 6.9.1 Exception identify[28115]: utility.c/ShredFile/1815/Exception
  Failed to remove: /var/tmp/magick-28115-Bk3VxNGPXIL.cache
  
I'm on OS X 10.10.4. My ImageMagick and Ghostscript version info below. Thanks in advance for any help.

Code: Select all

$ gs -version
GPL Ghostscript 9.16 (2015-03-30)
Copyright (C) 2015 Artifex Software, Inc.  All rights reserved.

$ identify -version
Version: ImageMagick 6.9.1-7 Q8 x86_64 2015-07-14 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms ltdl lzma png ps rsvg tiff webp wmf xml zlib

Re: policy.xml time limit not working as expected

Posted: 2015-07-21T17:24:36-07:00
by magick
The ImageMagick policy settings only affect ImageMagick algorithms, not the external delegate programs or libraries.

Re: policy.xml time limit not working as expected

Posted: 2015-07-21T17:53:07-07:00
by jkortegard
magick wrote:The ImageMagick policy settings only affect ImageMagick algorithms, not the external delegate programs or libraries.
Thanks, that definitely explains it. I'll look for a different solution.

As an interesting aside I left the identify command alone and it completed after an hour spent at that stalled location in the process. See timestamp jump in the debug output below.

Code: Select all

2015-07-21T15:17:42-07:00 0:00.000 0.000u 6.9.1 Resource identify[28115]: resource.c/AcquireUniqueFileResource/550/Resource
  Acquire /var/tmp/magick-28115-Bk3VxNGPXIL
2015-07-21T15:17:42-07:00 0:00.000 0.000u 6.9.1 Resource identify[28115]: resource.c/RelinquishUniqueFileResource/1039/Resource
  Relinquish /var/tmp/magick-28115-Bk3VxNGPXIL
2015-07-21T15:17:42-07:00 0:00.000 0.000u 6.9.1 Exception identify[28115]: utility.c/ShredFile/1815/Exception
  Failed to remove: /var/tmp/magick-28115-Bk3VxNGPXIL.cache
2015-07-21T16:17:50-07:00 0:00.361 0.361u 6.9.1 Resource identify[28115]: resource.c/RelinquishUniqueFileResource/1039/Resource
  Relinquish /var/tmp/magick-28115AfXwks077Zxu
2015-07-21T16:17:50-07:00 0:00.361 0.361u 6.9.1 Exception identify[28115]: utility.c/ShredFile/1815/Exception
  Failed to remove: /var/tmp/magick-28115AfXwks077Zxu.cache
2015-07-21T16:17:50-07:00 0:00.361 0.361u 6.9.1 Resource identify[28115]: resource.c/RelinquishUniqueFileResource/1039/Resource
  Relinquish /var/tmp/magick-28115STNiLiMVOfNs