Segmentation fault when converting .tif to .jpg

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
hpb

Segmentation fault when converting .tif to .jpg

Post by hpb »

We got 23.000 pictures from a customer. For most of them it worked fine to convert them to .jpg from any format. But some .tif pictures (about 500) showed segmentation faults or filled up the disk with files > 1 GB. The identify command crashes with the same fault for these pictures, which seem to have their origin in some Minolta camera. Color profiles are left out for testing. All images seem to have EXIF-Infos that are not recognized by ImageMagick and instead of giving only a warning, which can be "quietened", cause that real trouble. Here the debug session of such an image (image paths shortened by hand):

[hpb@pandora media]$ convert -debug All test1.tif -geometry "2048x2048>" test1.jpg
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: utility.c/ExpandFilenames/865/Configure
Command line: convert {-debug} {All} {test1.tif} {-geometry} {2048x2048>} {test1.jpg}
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/usr/share/ImageMagick-6.5.2/config/coder.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/usr/lib64/ImageMagick-6.5.2/config/coder.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/usr/share/doc/ImageMagick-6.5.2/coder.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/usr/share/ImageMagick-6.5.2/coder.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/home/hpb/.magick/coder.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "coder.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: coder.c/LoadCoderList/639/Configure
Loading coder configuration file "/usr/share/ImageMagick-6.5.2/config/coder.xml" ...
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Module convert[17822]: module.c/OpenModule/1154/Module
Searching for module "TIFF" using filename "tiff.la"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Module convert[17822]: module.c/GetMagickModulePath/549/Module
Searching for coder module file "tiff.la" ...
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Module convert[17822]: module.c/OpenModule/1163/Module
Opening module at path "/usr/lib64/ImageMagick-6.5.2/modules-Q16/coders/tiff.la"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Module convert[17822]: module.c/OpenModule/1190/Module
Method "RegisterTIFFImage" in module "TIFF" at address 0x2ae14e49cfe0
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Module convert[17822]: module.c/OpenModule/1204/Module
Method "UnregisterTIFFImage" in module "TIFF" at address 0x2ae14e49cfa0
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Policy convert[17822]: policy.c/IsRightsAuthorized/520/Policy
Domain: Path; rights=Read; pattern="test1.tif" ...
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Blob convert[17822]: blob.c/OpenBlob/2416/Blob
read 3 magic header bytes
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Cache convert[17822]: cache.c/DestroyPixelCacheInfo/1513/Cache
destroy
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/usr/share/ImageMagick-6.5.2/config/magic.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/usr/lib64/ImageMagick-6.5.2/config/magic.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/usr/share/doc/ImageMagick-6.5.2/magic.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/usr/share/ImageMagick-6.5.2/magic.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "/home/hpb/.magick/magic.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: configure.c/GetConfigureOptions/528/Configure
Searching for configure file: "magic.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: magic.c/LoadMagicList/682/Configure
Loading magic configure file "/usr/share/ImageMagick-6.5.2/config/magic.xml" ...
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Policy convert[17822]: policy.c/IsRightsAuthorized/520/Policy
Domain: Coder; rights=Read; pattern="TIFF" ...
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Policy convert[17822]: policy.c/IsRightsAuthorized/520/Policy
Domain: Path; rights=Read; pattern="test1.tif" ...
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Blob convert[17822]: blob.c/OpenBlob/2416/Blob
read 3 magic header bytes
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Cache convert[17822]: cache.c/DestroyPixelCacheInfo/1513/Cache
destroy
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Policy convert[17822]: policy.c/IsRightsAuthorized/520/Policy
Domain: Path; rights=Read; pattern="test1.tif" ...
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Blob convert[17822]: blob.c/OpenBlob/2416/Blob
read 3 magic header bytes
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Coder convert[17822]: tiff.c/ReadTIFFImage/696/Coder
Geometry: 448x617
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Coder convert[17822]: tiff.c/ReadTIFFImage/698/Coder
Interlace: 1
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Coder convert[17822]: tiff.c/ReadTIFFImage/700/Coder
Bits per sample: 8
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Coder convert[17822]: tiff.c/ReadTIFFImage/702/Coder
Min sample value: 0
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Coder convert[17822]: tiff.c/ReadTIFFImage/704/Coder
Max sample value: 255
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Coder convert[17822]: tiff.c/ReadTIFFImage/740/Coder
Photometric: SEPARATED
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Coder convert[17822]: tiff.c/ReadTIFFImage/756/Coder
Image depth: 8
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Locale convert[17822]: locale.c/GetLocaleOptions/498/Locale
Searching for locale file: "/usr/share/ImageMagick-6.5.2/config/locale.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Locale convert[17822]: locale.c/GetL
Searching for locale file: "/usr/lib64/ImageMagick-6.5.2/config/locale.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Locale convert[17822]: locale.c/GetL
Searching for locale file: "/usr/share/doc/ImageMagick-6.5.2/locale.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Locale convert[17822]: locale.c/GetL
Searching for locale file: "/usr/share/ImageMagick-6.5.2/locale.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Locale convert[17822]: locale.c/GetL
Searching for locale file: "/home/hpb/.magick/locale.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Locale convert[17822]: locale.c/GetL
Searching for locale file: "locale.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: locale.c/L
Loading locale configure file "/usr/lib64/ImageMagick-6.5.2/config/locale.xml"
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Configure convert[17822]: locale.c/L
Loading locale configure file "/usr/lib64/ImageMagick-6.5.2/config/english.xml
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Exception convert[17822]: tiff.c/TIF
test1.tif: unknown field with tag 40961 (
2009-08-10T11:58:54+02:00 0:01 0.000u 6.5.2 Exception convert[17822]: tiff.c/TIF
test1.tif: wrong data type 3 for "GainCon
Speicherzugriffsfehler

Last line means "segmentation fault" in German.

Here the URL of one of the pictures which show this behavior:
http://www.onlinekauf.de/test.tif
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Segmentation fault when converting .tif to .jpg

Post by fmw42 »

I think you have a bogus tif file. I downloaded it and tried to see its verbose info

identify -verbose test.tif
Bus Error
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Segmentation fault when converting .tif to .jpg

Post by magick »

We're investigating the problem. The stack trace suggests the bug is within the TIFF delegate library. In the mean-time download ImageMagick 6.5.4-10 and use this command:
  • convert -define tiff:ignore-exif=true test.tif test.jpg
hpb

Re: Segmentation fault when converting .tif to .jpg

Post by hpb »

Many thanks for the very quick help, this workaround worked for me and all 1.023 images converted perfectly.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Segmentation fault when converting .tif to .jpg

Post by magick »

If you get a chance, download ImageMagick-6.5.4-10. One of the EXIF properties was tickling a bug in the TIFF delegate library so we removed it. Your images should convert now without ignoring the EXIF properties.
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: Segmentation fault when converting .tif to .jpg

Post by broucaries »

Hi,

Have you reported the tiff bug upstream ?

Thank you bastien
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Segmentation fault when converting .tif to .jpg

Post by magick »

The ImageMagick developers have not definitely determined its a TIFF bug but it could be. We commented out two EXIF properties that TIFF is supposed to support (see coders/tiff.c) and the fault no longer occurs. We're waiting for additional reports before we make a final decision on where the bug lies (ImageMagick or TIFF).
Chris Riesen

Re: Segmentation fault when converting .tif to .jpg

Post by Chris Riesen »

Looks like I stumbled across the same thing:
# convert t.tif test.jpg
Segmentation Fault
# convert -define tiff:ignore-exif=true t.tif test.jpg
convert: t.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/546.

Second one works giving this warning though.

Is there a hack on the source that would solve the problem?

Version info:
# convert -v
Version: ImageMagick 6.5.4-10 2009-08-20 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Chris Riesen

Re: Segmentation fault when converting .tif to .jpg

Post by Chris Riesen »

Is there a tifflib / imagemagick version combo known to not have this bug and work? I need to be able to work with tiffs and I can't use the work around unless someone tells me which code line I could change to make this work around permanent for the moment. Thanks in advance.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Segmentation fault when converting .tif to .jpg

Post by magick »

Try ImageMagick 6.5.5-0. It does not extract the EXIF properties unless you use this option: -define tiff:exit=true.
Chris Riesen

Re: Segmentation fault when converting .tif to .jpg

Post by Chris Riesen »

Ok thanks a ton. Still gives a warning, but does the job otherwise perfect as well as in the interfaces (after a short magickwand recompile).
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: Segmentation fault when converting .tif to .jpg

Post by broucaries »

magick wrote:The ImageMagick developers have not definitely determined its a TIFF bug but it could be. We commented out two EXIF properties that TIFF is supposed to support (see coders/tiff.c) and the fault no longer occurs. We're waiting for additional reports before we make a final decision on where the bug lies (ImageMagick or TIFF).
Do you have taken a decision ?

Regard

Bastien
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Segmentation fault when converting .tif to .jpg

Post by magick »

We have not definitely determined its a bug in TIFF but it is likely a bug in TIFF library when it encounters certain EXIF profiles. We have not tested against TIFF 3.9.0 yet to determine if the bug is fixed.
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: Segmentation fault when converting .tif to .jpg

Post by broucaries »

seems that libtiff version 3.9.1-1 work like a charm
Post Reply