Page 1 of 1

SEGFAULT while reading PSD

Posted: 2013-01-10T03:01:17-07:00
by vladimir_ff
File: http://image.architonic.com/img_pro2-3/ ... s-97-b.psd
Code:

Code: Select all

    vector<char> buf;
    ifstream inputFile( (string(argv[1])).c_str() );
    copy( std::istreambuf_iterator<char>(inputFile),
          std::istreambuf_iterator<char>(),
          std::back_inserter(buf) );

    Blob blob( reinterpret_cast<const uint8_t*>(&buf[0]), buf.size() );
    Image image;
    image.read( blob );
Message:

*** glibc detected *** ./test_IM: double free or corruption (!prev): 0x09d791c8 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x6f751)[0xb7127751]
/lib/i386-linux-gnu/libc.so.6(+0x7107b)[0xb712907b]
/lib/i386-linux-gnu/libc.so.6(cfree+0x6d)[0xb712c20d]
/usr/lib/i386-linux-gnu/libstdc++.so.6(_ZdlPv+0x21)[0xb730c4d1]
/usr/lib/i386-linux-gnu/libstdc++.so.6(_ZdaPv+0x1d)[0xb730c52d]
/usr/local/lib/libMagick++.so.6(_ZN6Magick7BlobRefD2Ev+0x4e)[0xb77e84fe]
/usr/local/lib/libMagick++.so.6(_ZN6Magick4BlobD1Ev+0x56)[0xb77e7f16]
./test_IM[0x804938d]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0xb70cee37]
./test_IM[0x8049141]
======= Memory map: ========
08048000-0804f000 r-xp 00000000 08:01 9845041 /home/fedotov/work/test/test_IM/Debug/test_IM
0804f000-08050000 r--p 00006000 08:01 9845041 /home/fedotov/work/test/test_IM/Debug/test_IM
08050000-08051000 rw-p 00007000 08:01 9845041 /home/fedotov/work/test/test_IM/Debug/test_IM
09d77000-09dda000 rw-p 00000000 00:00 0 [heap]
b6a00000-b6a21000 rw-p 00000000 00:00 0
b6a21000-b6b00000 ---p 00000000 00:00 0
b6b6d000-b6b71000 rw-p 00000000 00:00 0
b6b71000-b6b75000 r-xp 00000000 08:01 4856045 /usr/lib/i386-linux-gnu/libXdmcp.so.6.0.0
b6b75000-b6b76000 r--p 00003000 08:01 4856045 /usr/lib/i386-linux-gnu/libXdmcp.so.6.0.0
b6b76000-b6b77000 rw-p 00004000 08:01 4856045 /usr/lib/i386-linux-gnu/libXdmcp.so.6.0.0
b6b77000-b6b79000 r-xp 00000000 08:01 4856037 /usr/lib/i386-linux-gnu/libXau.so.6.0.0
b6b79000-b6b7a000 r--p 00001000 08:01 4856037 /usr/lib/i386-linux-gnu/libXau.so.6.0.0
b6b7a000-b6b7b000 rw-p 00002000 08:01 4856037 /usr/lib/i386-linux-gnu/libXau.so.6.0.0
b6b7b000-b6b82000 r-xp 00000000 08:01 10617106 /lib/i386-linux-gnu/librt-2.13.so
b6b82000-b6b83000 r--p 00006000 08:01 10617106 /lib/i386-linux-gnu/librt-2.13.so
b6b83000-b6b84000 rw-p 00007000 08:01 10617106 /lib/i386-linux-gnu/librt-2.13.so
b6b84000-b6b9b000 r-xp 00000000 08:01 4856185 /usr/lib/i386-linux-gnu/libxcb.so.1.1.0
b6b9b000-b6b9c000 r--p 00016000 08:01 4856185 /usr/lib/i386-linux-gnu/libxcb.so.1.1.0
b6b9c000-b6b9d000 rw-p 00017000 08:01 4856185 /usr/lib/i386-linux-gnu/libxcb.so.1.1.0
b6b9d000-b6ba0000 r-xp 00000000 08:01 10617746 /lib/i386-linux-gnu/libuuid.so.1.3.0
b6ba0000-b6ba1000 r--p 00002000 08:01 10617746 /lib/i386-linux-gnu/libuuid.so.1.3.0
b6ba1000-b6ba2000 rw-p 00003000 08:01 10617746 /lib/i386-linux-gnu/libuuid.so.1.3.0
b6ba2000-b6ba3000 rw-p 00000000 00:00 0
b6ba3000-b6ba5000 r-xp 00000000 08:01 10617108 /lib/i386-linux-gnu/libdl-2.13.so
b6ba5000-b6ba6000 r--p 00001000 08:01 10617108 /lib/i386-linux-gnu/libdl-2.13.so
b6ba6000-b6ba7000 rw-p 00002000 08:01 10617108 /lib/i386-linux-gnu/libdl-2.13.so
b6ba7000-b6bb2000 r-xp 00000000 08:01 4856114 /usr/lib/i386-linux-gnu/libgomp.so.1.0.0
b6bb2000-b6bb3000 r--p 0000a000 08:01 4856114 /usr/lib/i386-linux-gnu/libgomp.so.1.0.0
b6bb3000-b6bb4000 rw-p 0000b000 08:01 4856114 /usr/lib/i386-linux-gnu/libgomp.so.1.0.0
b6bb4000-b6cca000 r-xp 00000000 08:01 4856035 /usr/lib/i386-linux-gnu/libX11.so.6.3.0
b6cca000-b6ccb000 ---p 00116000 08:01 4856035 /usr/lib/i386-linux-gnu/libX11.so.6.3.0
b6ccb000-b6ccc000 r--p 00116000 08:01 4856035 /usr/lib/i386-linux-gnu/libX11.so.6.3.0
b6ccc000-b6cce000 rw-p 00117000 08:01 4856035 /usr/lib/i386-linux-gnu/libX11.so.6.3.0
b6cce000-b6ccf000 rw-p 00000000 00:00 0
b6ccf000-b6ce3000 r-xp 00000000 08:01 4856029 /usr/lib/i386-linux-gnu/libICE.so.6.3.0
b6ce3000-b6ce4000 r--p 00013000 08:01 4856029 /usr/lib/i386-linux-gnu/libICE.so.6.3.0
b6ce4000-b6ce5000 rw-p 00014000 08:01 4856029 /usr/lib/i386-linux-gnu/libICE.so.6.3.0
b6ce5000-b6ce8000 rw-p 00000000 00:00 0
b6ce8000-b6cee000 r-xp 00000000 08:01 4856031 /usr/lib/i386-linux-gnu/libSM.so.6.0.1
b6cee000-b6cef000 r--p 00005000 08:01 4856031 /usr/lib/i386-linux-gnu/libSM.so.6.0.1
b6cef000-b6cf0000 rw-p 00006000 08:01 4856031 /usr/lib/i386-linux-gnu/libSM.so.6.0.1
b6cf0000-b6d03000 r-xp 00000000 08:01 10617748 /lib/i386-linux-gnu/libz.so.1.2.3.4
b6d03000-b6d04000 r--p 00012000 08:01 10617748 /lib/i386-linux-gnu/libz.so.1.2.3.4
b6d04000-b6d05000 rw-p 00013000 08:01 10617748 /lib/i386-linux-gnu/libz.so.1.2.3.4
b6d05000-b6e28000 r-xp 00000000 08:01 4850505 /usr/lib/libxml2.so.2.7.8
b6e28000-b6e2c000 r--p 00123000 08:01 4850505 /usr/lib/libxml2.so.2.7.8
b6e2c000-b6e2d000 rw-p 00127000 08:01 4850505 /usr/lib/libxml2.so.2.7.8
b6e2d000-b6e2e000 rw-p 00000000 00:00 0
b6e2e000-b6e3d000 r-xp 00000000 08:01 10624570 /lib/libbz2.so.1.0.4
b6e3d000-b6e3e000 r--p 0000f000 08:01 10624570 /lib/libbz2.so.1.0.4
b6e3e000-b6e3f000 rw-p 00010000 08:01 10624570 /lib/libbz2.so.1.0.4
b6e3f000-b6e8d000 r-xp 00000000 08:01 4856061 /usr/lib/i386-linux-gnu/libXt.so.6.0.0
b6e8d000-b6e8e000 r--p 0004d000 08:01 4856061 /usr/lib/i386-linux-gnu/libXt.so.6.0.0
b6e8e000-b6e91000 rw-p 0004e000 08:01 4856061 /usr/lib/i386-linux-gnu/libXt.so.6.0.0
b6e91000-b6e92000 rw-p 00000000 00:00 0
b6e92000-b6e9f000 r-xp 00000000 08:01 4856047 /usr/lib/i386-linux-gnu/libXext.so.6.4.0
b6e9f000-b6ea0000 r--p 0000c000 08:01 4856047 /usr/lib/i386-linux-gnu/libXext.so.6.4.0
b6ea0000-b6ea1000 rw-p 0000d000 08:01 4856047 /usr/lib/i386-linux-gnu/libXext.so.6.4.0
b6ea1000-b6ec4000 r-xp 00000000 08:01 10625573 /lib/i386-linux-gnu/libpng12.so.0.44.0
b6ec4000-b6ec5000 r--p 00022000 08:01 10625573 /lib/i386-linux-gnu/libpng12.so.0.44.0
b6ec5000-b6ec6000 rw-p 00023000 08:01 10625573 /lib/i386-linux-gnu/libpng12.so.0.44.0
b6ec6000-b6efb000 r-xp 00000000 08:01 4859418 /usr/lib/libjpeg.so.8.0.2
b6efb000-b6efc000 r--p 00034000 08:01 4859418 /usr/lib/libjpeg.so.8.0.2
b6efc000-b6efd000 rw-p 00035000 08:01 4859418 /usr/lib/libjpeg.so.8.0.2
b6efd000-b6f7e000 r-xp 00000000 08:01 4856357 /usr/lib/i386-linux-gnu/libfreetype.so.6.6.2
b6f7e000-b6f82000 r--p 00080000 08:01 4856357 /usr/lib/i386-linux-gnu/libfreetype.so.6.6.2
b6f82000-b6f83000 rw-p 00084000 08:01 4856357 /usr/lib/i386-linux-gnu/libfreetype.so.6.6.2
b6f83000-b709b000 r-xp 00000000 08:01 5245783 /usr/local/lib/libMagickWand.so.6.0.0
b709b000-b709c000 r--p 00117000 08:01 5245783 /usr/local/lib/libMagickWand.so.6.0.0
b709c000-b709e000 rw-p 00118000 08:01 5245783 /usr/local/lib/libMagickWand.so.6.0.0
b709e000-b709f000 rw-p 00000000 00:00 0
b709f000-b70b4000 r-xp 00000000 08:01 10617114 /lib/i386-linux-gnu/libpthread-2.13.so
b70b4000-b70b5000 r--p 00015000 08:01 10617114 /lib/i386-linux-gnu/libpthread-2.13.so

IM 6.8.0-1

Re: SEGFAULT while reading PSD

Posted: 2013-01-10T04:33:52-07:00
by magick
We tried your image with ImageMagick 6.8.1-9, the latest release. The image read fine without any memory corruption.

Re: SEGFAULT while reading PSD

Posted: 2013-01-11T05:05:43-07:00
by vladimir_ff
I just tried it with ImageMagick 6.8.1-9 2013-01-10 (Q16) (Ubuntu 11.04)
And I have memory corruption with only file which I posted below.
Did you try it with my code? It doesn't happen when using console utilities.
This is full version of my code:

Code: Select all

#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <Magick++.h>
#include <cmath>
#include "boost/filesystem/operations.hpp"

using namespace std;
using namespace boost;
using namespace Magick;


int main(int argc, char *argv[])
{
    vector<char> buf;
    ifstream inputFile( (string(argv[1])).c_str() );
    copy( std::istreambuf_iterator<char>(inputFile),
          std::istreambuf_iterator<char>(),
          std::back_inserter(buf) );

    Blob blob( reinterpret_cast<const uint8_t*>(&buf[0]), buf.size() );
    Image image;
    image.read( blob );

    return 0;
}

Re: SEGFAULT while reading PSD

Posted: 2013-01-11T05:53:33-07:00
by magick
Stand by, valgrind is returning some memory corruption. We're investigating.

Re: SEGFAULT while reading PSD

Posted: 2013-01-15T01:50:46-07:00
by broucaries
coumd you please cc me the patch?

debian will need it