Page 1 of 1

stream segfaults while reading certain TIFFs

Posted: 2010-05-13T13:02:35-07:00
by wildbug
stream is segfaulting while reading certain multipage TIFF files. I was using it to pipe input to convert for reading very large files. If I convert them to vips (raw) and back to TIFF using raw2tiff (from libtiff), then stream reads them just fine. The file used to generate the debugging output below is about 10GB, but I'll provide a link to a smaller file (75MB) that I have confirmed causes segmentation faults as well.

-debug All:

Code: Select all

me@atlas /tmp $ stream -map rgb -storage-type char -extract 72889x8+0+0 -debug All /mnt/i/tiff/24465.tif'[0]' /dev/null
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: utility.c/ExpandFilenames/871/Configure
  Command line: stream {-map} {rgb} {-storage-type} {char} {-extract} {72889x8+0+0} {-debug} {All} {/mnt/i/tiff/24465.tif[0]} {/dev/null}
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Policy stream[2711]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Path; rights=Write; pattern="/dev/null" ...
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/share/ImageMagick-6.6.1/config/coder.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/lib64/ImageMagick-6.6.1/config/coder.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/share/doc/imagemagick-6.6.1.2/coder.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/share/ImageMagick-6.6.1/coder.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/home/me/.magick/coder.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "coder.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: coder.c/LoadCoderList/692/Configure
  Loading coder configuration file "/usr/share/ImageMagick-6.6.1/config/coder.xml" ...
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Module stream[2711]: module.c/OpenModule/1215/Module
  Searching for module "TIFF" using filename "tiff.la"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Module stream[2711]: module.c/GetMagickModulePath/551/Module
  Searching for coder module file "tiff.la" ...
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Module stream[2711]: module.c/OpenModule/1224/Module
  Opening module at path "/usr/lib64/ImageMagick-6.6.1/modules-Q16/coders/tiff.la"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Module stream[2711]: module.c/OpenModule/1251/Module
  Method "RegisterTIFFImage" in module "TIFF" at address 0x7fca53e3c2a0
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Module stream[2711]: module.c/OpenModule/1265/Module
  Method "UnregisterTIFFImage" in module "TIFF" at address 0x7fca53e3c180
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Policy stream[2711]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Path; rights=Read; pattern="/mnt/i/tiff/24465.tif" ...
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Blob stream[2711]: blob.c/OpenBlob/2416/Blob
    read 3 magic header bytes
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/share/ImageMagick-6.6.1/config/magic.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/lib64/ImageMagick-6.6.1/config/magic.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/share/doc/imagemagick-6.6.1.2/magic.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/usr/share/ImageMagick-6.6.1/magic.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "/home/me/.magick/magic.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: configure.c/GetConfigureOptions/564/Configure
  Searching for configure file: "magic.xml"
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Configure stream[2711]: magic.c/LoadMagicList/677/Configure
  Loading magic configure file "/usr/share/ImageMagick-6.6.1/config/magic.xml" ...
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Policy stream[2711]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Coder; rights=Read; pattern="TIFF64" ...
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Policy stream[2711]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Path; rights=Read; pattern="/mnt/i/tiff/24465.tif" ...
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Blob stream[2711]: blob.c/OpenBlob/2416/Blob
    read 3 magic header bytes
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Policy stream[2711]: policy.c/IsRightsAuthorized/485/Policy
  Domain: Path; rights=Read; pattern="/mnt/i/tiff/24465.tif" ...
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Blob stream[2711]: blob.c/OpenBlob/2416/Blob
    read 3 magic header bytes
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Coder stream[2711]: tiff.c/ReadTIFFImage/912/Coder
  Geometry: 72889x56791
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Coder stream[2711]: tiff.c/ReadTIFFImage/914/Coder
  Interlace: 1
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Coder stream[2711]: tiff.c/ReadTIFFImage/916/Coder
  Bits per sample: 8
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Coder stream[2711]: tiff.c/ReadTIFFImage/918/Coder
  Min sample value: 0
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Coder stream[2711]: tiff.c/ReadTIFFImage/920/Coder
  Max sample value: 255
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Coder stream[2711]: tiff.c/ReadTIFFImage/922/Coder
  Photometric interpretation: RGB
2010-05-13T11:49:21-04:00 0:00.000 0.000u 6.6.1 Coder stream[2711]: tiff.c/ReadTIFFImage/929/Coder
  Image depth: 8
Segmentation fault
gdb backtrace:

Code: Select all

(gdb) run -map rgb -storage-type char -extract 72889x8+0+0 /mnt/i/tiff/24465.tif'[0]' /dev/null
Starting program: /usr/bin/stream -map rgb -storage-type char -extract 72889x8+0+0 /mnt/i/tiff/24465.tif'[0]' /dev/null
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7aec0f2 in StreamImagePixels () from /usr/lib/libMagickCore.so.3
(gdb) backtrace
#0  0x00007ffff7aec0f2 in StreamImagePixels () from /usr/lib/libMagickCore.so.3
#1  0x00007ffff7aee4b6 in WriteStreamImage () from /usr/lib/libMagickCore.so.3
#2  0x00007ffff7aee9b9 in SyncAuthenticPixelsStream () from /usr/lib/libMagickCore.so.3
#3  0x00007ffff3fe8315 in ReadTIFFImage () from /usr/lib64/ImageMagick-6.6.1/modules-Q16/coders/tiff.so
#4  0x00007ffff7a03bbe in ReadImage () from /usr/lib/libMagickCore.so.3
#5  0x00007ffff7aee68c in ReadStream () from /usr/lib/libMagickCore.so.3
#6  0x00007ffff7aee808 in StreamImage () from /usr/lib/libMagickCore.so.3
#7  0x00007ffff776606c in StreamImageCommand () from /usr/lib/libMagickWand.so.3
#8  0x00007ffff7725cf2 in MagickCommandGenesis () from /usr/lib/libMagickWand.so.3
#9  0x0000000000400ab5 in main ()
Sample image

Re: stream segfaults while reading certain TIFFs

Posted: 2010-05-13T18:44:44-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.6.1-9 Beta available by sometime tomorrow. Thanks.

Re: stream segfaults while reading certain TIFFs

Posted: 2010-05-14T07:52:11-07:00
by wildbug
Great, thanks for the quick fix!