Imagick / imagick

🌈 The Imagick PHP extension 🌈
http://pecl.php.net/imagick
Other
548 stars 140 forks source link

Imagick causes a segfault on Windows when loading invalid image in constructor #252

Open mlocati opened 6 years ago

mlocati commented 6 years ago

Steps to reproduce the problem

C:\> php -r "try { new Imagick('not-existing-file'); die('ok'); } catch (Throwable $throwable) { var_dump($throwable); die('ko'); }"

Expected result

PHP should print the details of $throwable.

Actual result

PHP is killed, and in the Windows Events Log I have this error: Exception code: 0xc0000409 Patho to the application: C:\Path\To\php.exe Path to the module: C:\Path\To\ext\php_imagick.dll

Environment details


C:\> ver
Microsoft Windows [Versione 10.0.17134.228]

C:\> php -v
PHP 7.1.21 (cli) (built: Aug 15 2018 23:05:59) ( NTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

C:\> php --ri imagick

imagick

imagick module => enabled
imagick module version => 3.4.3
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 6.9.3-7 Q16 x64 2016-03-27 http://www.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.9.3-7 Q16 x64 2016-03-27 http://www.imagemagick.org
ImageMagick copyright => Copyright (C) 1999-2015 ImageMagick Studio LLC
ImageMagick release date => 2016-03-27
ImageMagick number of supported formats:  => 234
ImageMagick supported formats => 3FR, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CR2, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPS, DPX, DXT1, DXT5, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FITS, FPX, FRACTAL, FTS, G3, GIF, GIF87, GRADIENT, GRAY, GROUP4, GV, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCREENSHOT, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBP, WMF, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, YCbCr, YCbCrA, YUV

Directive => Local Value => Master Value
imagick.locale_fix => 0 => 0
imagick.skip_version_check => 0 => 0
imagick.progress_monitor => 0 => 0
Danack commented 6 years ago

What happens when you try to process this image with ImageMagick's convert command?

Exception code 0xc0000409 doesn't appear to mean much other than possibly "something is wrong with your system" which....probably isn't helpful.

Is there any actual text description in an error log?

There's very little I'm likely to be able to do on this side of the ImageMagick libary. Depending on if convert also shows a fatal exception - possibly you'll need to open an issue at https://github.com/ImageMagick/ImageMagick

Somewhat interesting that opening it as a blob makes it not fatal....

mlocati commented 6 years ago

What happens when you try to process this image with ImageMagick's convert command?

C:\> C:\Path\To\convert.exe this-file-does-not-exist out.jpg
convert.exe: UnableToOpenBlob `this-file-does-not-exist': No such file or directory @ error/blob.c/OpenBlob/2702.
convert.exe: UnableToOpenConfigureFile `delegates.xml' @ warning/configure.c/GetConfigureOptions/706.
convert.exe: UnableToOpenBlob `this-file-does-not-exist': No such file or directory @ error/blob.c/OpenBlob/2702.
convert.exe: NoDecodeDelegateForThisImageFormat `' @ error/constitute.c/ReadImage/501.
convert.exe: NoImagesDefined `out.pt.jpg' @ error/convert.c/ConvertImageCommand/3252

Exception code 0xc0000409 doesn't appear to mean much other than possibly "something is wrong with your system" which....probably isn't helpful. Is there any actual text description in an error log?

Nope, just these details (translated from Italian):

Name of application that generated the error: php.exe, version: 7.1.21.0, timestamp: 0x5b74b219
Name of module that generated the error: php_imagick.dll, version: 7.1.0.0, timestamp: 0x58927084
Exception code: 0xc0000409
Error offset 0x0000000000023a2c
ID of process that generated the error: 0x738
Start time of application that generatd the error: 0x01d439e031d4e46b
Path to the application that generated the error: C:\path\to\php.exe
Path to the module that generated the error: C:\path\to\ext\php_imagick.dll
Report ID: 6e45f191-7ed9-4bdd-b698-62f75b1e1b25
Full name of the package that generated the error: 
Application ID related to the package that generated the error:

Please remark that this is happening to me only on the 64 bit version of PHP 7.1, using ImageMagick-6.9.3-7-vc14-x64. On the 32 bit of PHP 7.1 this does not happen.

avvertix commented 6 years ago

Same problem happens to me on PHP 7.1 64bit when reading a PDF file on Windows. Linux version works fine.

imagick module => enabled
imagick module version => 3.4.3
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 6.9.3-7 Q16 x64 2016-03-27 http://www.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.9.3-7 Q16 x64 2016-03-27 http://www.imagemagick.org
ImageMagick copyright => Copyright (C) 1999-2015 ImageMagick Studio LLC
ImageMagick release date => 2016-03-27
ImageMagick number of supported formats:  => 234
ImageMagick supported formats => 3FR, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CR2, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPS, DPX, DXT1, DXT5, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FITS, FPX, FRACTAL, FTS, G3, GIF, GIF87, GRADIENT, GRAY, GROUP4, GV, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC,
JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCREENSHOT, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBP, WMF, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, YCbCr, YCbCrA, YUV

Directive => Local Value => Master Value
imagick.locale_fix => 0 => 0
imagick.skip_version_check => 0 => 0
imagick.progress_monitor => 0 => 0