Crash on lack of space in /tmp

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
Hubbitus
Posts: 66
Joined: 2010-05-04T10:50:21-07:00
Authentication code: 8675308
Location: Russia, Saint-Petersburg

Crash on lack of space in /tmp

Post by Hubbitus »

https://bugzilla.redhat.com/show_bug.cgi?id=1006658

This thread have lot of irrelevant comment, but please concern one, citing:
Should convert crash if there isn't sufficient space in /tmp for it's operation (no matter where /tmp is actually mounted?) - No. That's a bug. convert should detect a lack of space and fail gracefully - cleaning up any files that had been created along the way.
Could it be checked please? It will be extremely usable.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Crash on lack of space in /tmp

Post by snibgo »

It is also possible for convert to run out of tmp space, create an incorrect image, and not fail. In my view, this is worse than crashing.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Crash on lack of space in /tmp

Post by magick »

The solution to this problem is to add -synchronize to the command line. This option ensures that disk space allocated to the pixel cache exists before any pixels are written (see posix_fallocate(3)). Without it, the pixel cache sets the disk extent but does not preallocate the disk for performance reasons. When the disk-based pixel cache is memory-mapped, again for for performance reasons, the OS issues a SIGBUS if not enough disk is available. This behavior is not specific to ImageMagick. It is expected in any program that memory-maps a disk file that is not fully populated and subsequently runs out of disk on the device (see http://www.linuxprogrammingblog.com/cod ... S-handling for a similar mmap() issue).

With -synchronize you will see a slow down in performance for any image that requires more memory than the system can provide. However, ImageMagick will exit gracefully.

We used to catch the SIGBUS signal but it proved problematic. We will revisit catching the SIGBUS and see if we can come up with a reasonable way to exit ImageMagick gracefully.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Crash on lack of space in /tmp

Post by snibgo »

Thanks. "-synchronize" is documented: http://www.imagemagick.org/script/comma ... ynchronize
snibgo's IM pages: im.snibgo.com
Post Reply