Page 1 of 1

[PerlMagick] Segment Fault: TIFF->PNG

Posted: 2008-11-18T15:55:24-07:00
by xiconfjs
Hi Guys,

I am using the Perl-Modul "Image::Magick" with ImageMagick as backend. But I have a problem with converting a picture. I know, that this file is corrupted, but ImageMagick should not get a buffer-overflow. If the script trys to "Read()" the picture, it gets a "Segment Fault".

The corrupted file is a TIFF-file that should be converted to PNG.

Code: Select all

#!/usr/bin/perl -w

use strict;
use warnings;
use Image::Magick;
 
$|=1;

my $pic_name = "05.tif";
my $image = Image::Magick->new;

print "[start] reading\n";
my $x = $image->Read($pic_name);            # hier I get the "Segment Fault"
print "[stop] reading\n";                   # this text will not be displayed

my ($width,$height) = $image->Get('width','height');
$x = $image->Resize(geometry=>'400x400');
$x = $image->Write("05_big.png");
$x = $image->Resize(geometry=>'100x100');
$x = $image->Write("05_small.png");

Code: Select all

This is the test-picture:
http://db.nixzuholen.de/test/05.tif

Code: Select all

Version: ImageMagick 6.4.4 2008-10-22 Q16 http://www.imagemagick.org
perl -MImage::Magick -e 'print "$Image::Magick::VERSION"' -> 6.4.4

Re: [PerlMagick] Segment Fault: TIFF->PNG

Posted: 2008-11-18T16:27:59-07:00
by magick
We agree, ImageMagick should not fault on a corrupt image. We downloaded and converted your image with the latest ImageMagick release, 6.4.5-8, and it converted / displayed without complaint.

Re: [PerlMagick] Segment Fault: TIFF->PNG

Posted: 2008-11-18T16:41:51-07:00
by xiconfjs
thanks for fast reply. Is there a posibility for you, to convert the image with the 6.4.4 version, so I can be sure, that this is a problem of this version?

Thanks xiconfjs

Re: [PerlMagick] Segment Fault: TIFF->PNG

Posted: 2008-11-20T01:56:21-07:00
by xiconfjs
Hi,

I installed the latest stable version of ImageMagick 6.4.5, but the problem still exists. I think it's a problem with the tiff-library, so I will try to install the latest BETA version of libtiff, to solve this problem. Here is the debug-log of "convert":

Code: Select all

2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: utility.c/ExpandFilenames/808/Configure
  Command line: /usr/local/bin/convert {-debug} {All} {05.tif} {05.png}
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/usr/local/share/ImageMagick-6.4.5/config/coder.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/usr/local/lib/ImageMagick-6.4.5/config/coder.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/usr/local/share/doc/ImageMagick-6.4.5/coder.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/usr/local/share/ImageMagick-6.4.5/coder.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/private/var/root/.magick/coder.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "coder.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: coder.c/LoadCoderList/638/Configure
  Loading coder configuration file "/usr/local/share/ImageMagick-6.4.5/config/coder.xml" ...
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Module convert[23756]: module.c/OpenModule/1120/Module
  Searching for module "TIFF" using filename "tiff.la"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Module convert[23756]: module.c/GetMagickModulePath/528/Module
  Searching for coder module file "tiff.la" ...
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Module convert[23756]: module.c/OpenModule/1129/Module
  Opening module at path "/usr/local/lib/ImageMagick-6.4.5/modules-Q16/coders/tiff.la"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Module convert[23756]: module.c/OpenModule/1156/Module
  Method "RegisterTIFFImage" in module "TIFF" at address 0xe3050
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Module convert[23756]: module.c/OpenModule/1170/Module
  Method "UnregisterTIFFImage" in module "TIFF" at address 0xe32b0
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Blob convert[23756]: blob.c/OpenBlob/2330/Blob
    read 3 magic header bytes
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Cache convert[23756]: cache.c/DestroyCacheInfo/1931/Cache
  destroy 
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/usr/local/share/ImageMagick-6.4.5/config/magic.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/usr/local/lib/ImageMagick-6.4.5/config/magic.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/usr/local/share/doc/ImageMagick-6.4.5/magic.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/usr/local/share/ImageMagick-6.4.5/magic.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "/private/var/root/.magick/magic.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: configure.c/GetConfigureOptions/528/Configure
  Searching for configure file: "magic.xml"
2008-11-20T09:47:16+01:00 0:01 0.000u 6.4.5 Configure convert[23756]: magic.c/LoadMagicList/681/Configure
  Loading magic configure file "/usr/local/share/ImageMagick-6.4.5/config/magic.xml" ...
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Blob convert[23756]: blob.c/OpenBlob/2330/Blob
    read 3 magic header bytes
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Cache convert[23756]: cache.c/DestroyCacheInfo/1931/Cache
  destroy 
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Blob convert[23756]: blob.c/OpenBlob/2330/Blob
    read 3 magic header bytes
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/usr/local/share/ImageMagick-6.4.5/config/locale.xml"
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/usr/local/lib/ImageMagick-6.4.5/config/locale.xml"
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/usr/local/share/doc/ImageMagick-6.4.5/locale.xml"
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/usr/local/share/ImageMagick-6.4.5/locale.xml"
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/private/var/root/.magick/locale.xml"
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "locale.xml"
2008-11-20T09:47:16+01:00 0:01 0.010u 6.4.5 Configure convert[23756]: locale.c/LoadLocaleList/779/Configure
  Loading locale configure file "/usr/local/lib/ImageMagick-6.4.5/config/locale.xml" ...
2008-11-20T09:47:16+01:00 0:01 0.020u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/usr/local/share/ImageMagick-6.4.5/config/english.xml"
2008-11-20T09:47:16+01:00 0:01 0.020u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/usr/local/lib/ImageMagick-6.4.5/config/english.xml"
2008-11-20T09:47:16+01:00 0:01 0.020u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/usr/local/share/doc/ImageMagick-6.4.5/english.xml"
2008-11-20T09:47:16+01:00 0:01 0.020u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/usr/local/share/ImageMagick-6.4.5/english.xml"
2008-11-20T09:47:16+01:00 0:01 0.020u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "/private/var/root/.magick/english.xml"
2008-11-20T09:47:16+01:00 0:01 0.020u 6.4.5 Locale convert[23756]: locale.c/GetLocaleOptions/498/Locale
  Searching for locale file: "english.xml"
2008-11-20T09:47:16+01:00 0:01 0.020u 6.4.5 Configure convert[23756]: locale.c/LoadLocaleList/779/Configure
  Loading locale configure file "/usr/local/lib/ImageMagick-6.4.5/config/english.xml" ...
2008-11-20T09:47:16+01:00 0:01 0.040u 6.4.5 Exception convert[23756]: tiff.c/TIFFWarnings/522/Exception
  05.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory'
2008-11-20T09:47:16+01:00 0:01 0.040u 6.4.5 Coder convert[23756]: tiff.c/ReadTIFFImage/696/Coder
  Geometry: 292x413
2008-11-20T09:47:16+01:00 0:01 0.040u 6.4.5 Coder convert[23756]: tiff.c/ReadTIFFImage/698/Coder
  Interlace: 1
2008-11-20T09:47:16+01:00 0:01 0.040u 6.4.5 Coder convert[23756]: tiff.c/ReadTIFFImage/700/Coder
  Bits per sample: 8
2008-11-20T09:47:16+01:00 0:01 0.040u 6.4.5 Coder convert[23756]: tiff.c/ReadTIFFImage/702/Coder
  Min sample value: 0
2008-11-20T09:47:16+01:00 0:01 0.040u 6.4.5 Coder convert[23756]: tiff.c/ReadTIFFImage/704/Coder
  Max sample value: 255
2008-11-20T09:47:16+01:00 0:01 0.040u 6.4.5 Coder convert[23756]: tiff.c/ReadTIFFImage/740/Coder
  Photometric: SEPARATED
Segmentation fault

Re: [PerlMagick] Segment Fault: TIFF->PNG

Posted: 2008-11-20T03:50:10-07:00
by xiconfjs
Ok, the problem is solved.

I installed the latest version of libtiff (3.9.0 BETA), and now the segment fault is gone. So the bug was in libtiff not in ImageMagick.


greetz xiconfjs