I am getting consistent bus errors from ImageMagick tools when processing certain files in certain orders
I can 'identify a.jpg', 'identify b.jpg', 'identify b.jpg a.jpg', but when I try to 'identify a.jpg b.jpg' (or even 'identify a.jpg; identify b.jpg') I get a Bus Error with the following backtrace:
#0 0x00007ffff6f3869b in memcpy () from /lib/libc.so.6
#1 0x00007ffff79f5144 in ReadBlob () from /usr/lib/libMagickCore.so.2
#2 0x00007ffff7a96c4e in SetImageInfo () from /usr/lib/libMagickCore.so.2
#3 0x00007ffff7a21b20 in ReadImage () from /usr/lib/libMagickCore.so.2
#4 0x00007ffff7af59bc in ReadStream () from /usr/lib/libMagickCore.so.2
#5 0x00007ffff7a22df7 in PingImage () from /usr/lib/libMagickCore.so.2
#6 0x00007ffff7a2304b in PingImages () from /usr/lib/libMagickCore.so.2
#7 0x00007ffff7730d57 in IdentifyImageCommand () from /usr/lib/libMagickWand.so.2
#8 0x0000000000400fd7 in ?? ()
#9 0x00007ffff6ed4abd in __libc_start_main () from /lib/libc.so.6
#10 0x0000000000400dd9 in ?? ()
#11 0x00007fffffffe708 in ?? ()
#12 0x000000000000001c in ?? ()
#13 0x0000000000000003 in ?? ()
#14 0x00007fffffffe92c in ?? ()
#15 0x00007fffffffe93e in ?? ()
#16 0x00007fffffffe966 in ?? ()
#17 0x0000000000000000 in ?? ()
When I copy the files to a different disk the crash goes away regardless of access order. I should also note that these files are being accessed over CIFS. Could a disk issue be causing this bizzarre ImageMagick crash, even when the files seem otherwise fine? I can 'md5sum a.jpg b.jpg' repeatedly with no issue (and same results each time), but every time I 'identify a.jpg b.jpg' or make a montage in that same order, ImageMagick crashes.
Strange Bus Error from montage and identify
Re: Strange Bus Error from montage and identify
We suspect the bug is related to memory mapping and could be a problem with the CIFS driver. To verify, comment out the MAGICKCORE_HAVE_MMAP_FILEIO define in magick/magick-config.h file and rebuild and reinstall ImageMagick. Does that fix the problem? If that does not fix the problem, rebuild with debugging turned on (-g) and rerun gdb so we can get a stack trace with source line numbers. Also make sure you have the very latest ImageMagick release.
Re: Strange Bus Error from montage and identify
Thanks for your quick and helpful reply. Unfortunately, I don't have the libjpeg headers in my target environment, so building ImageMagick from source is more than I should wade into right now. It looks like the installed version is somewhat out of date:
>aptitude show imagemagick
...
Version: 7:6.5.1.0-1.1ubuntu3
For the sake of this client project, I need to find a quicker workaround for this issue and will likely whip something out using PIL instead. If this is a CIFS issue (which seems reasonable), is there anything ImageMagick could fix without turning off memory map by default? When I've accomplished my primary goal, I'm willing to spend some personal time testing this out, but only if testing the custom build would be helpful to ImageMagick and not just to help me workaround this issue.
>aptitude show imagemagick
...
Version: 7:6.5.1.0-1.1ubuntu3
For the sake of this client project, I need to find a quicker workaround for this issue and will likely whip something out using PIL instead. If this is a CIFS issue (which seems reasonable), is there anything ImageMagick could fix without turning off memory map by default? When I've accomplished my primary goal, I'm willing to spend some personal time testing this out, but only if testing the custom build would be helpful to ImageMagick and not just to help me workaround this issue.
Re: Strange Bus Error from montage and identify
After converting to PIL, I still experienced issues with the exact same files, but was finally able to snag a corrupt copy of one of the images. I am now almost certain that it is due to a CIFS bug (https://bugs.launchpad.net/ubuntu/+sour ... bug/491288) unpatched in the distro I'm using, and things are working much better over SSHFS. ImageMagick does properly handle detect the error (without crashing, of course) when accessing the corrupted copy via a sane filesystem.