Skip to content

Image Magick setOption crashes #14

Closed

Description

@Danack

Hi,

This is possibly a bug in Image Magick itself, rather than the Imagick extension.

<?php

$imagick = new Imagick(realpath("../images/TestImage.jpg"));
$imagick->setImageFormat('jpg');
$imagick->setOption('jpeg:extent', '30kb');

$crash = true;

if ($crash) {
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}
else {
    $tempFilename = tempnam('./', 'imagick');
    $imagick->writeimage(realpath($tempFilename));
    header("Content-Type: image/jpg");
    echo file_get_contents($tempFilename);
}

The 'crash' version of generating the image blob crashes with the error message below:

*** glibc detected *** /usr/local/bin/php: double free or corruption (!prev): 0x0000000002671ce0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x760e6)[0x7f285292c0e6]
/lib64/libc.so.6(+0x78c13)[0x7f285292ec13]
/usr/lib64/libjpeg.so.62(+0x2919a)[0x7f285613519a]
/usr/lib64/libjpeg.so.62(jpeg_abort+0x15)[0x7f285611e185]
/usr/local/lib/libMagickCore-6.Q16.so.1(+0x25142b)[0x7f2848a3e42b]
/usr/local/lib/libMagickCore-6.Q16.so.1(+0x24f9fb)[0x7f2848a3c9fb]
/usr/local/lib/libMagickCore-6.Q16.so.1(WriteImage+0x5fc)[0x7f2848883e5c]
/usr/local/lib/libMagickCore-6.Q16.so.1(ImageToBlob+0x154)[0x7f28488530d4]
/usr/local/lib/php/extensions/no-debug-zts-20121212/imagick.so(zim_imagick_getimageblob+0x83)[0x7f28490ab8a3]
/usr/local/bin/php[0x7beaf2]
/usr/local/bin/php(execute_ex+0x4b)[0x7aec0b]
/usr/local/bin/php(zend_execute_scripts+0x1e7)[0x72ebb7]
/usr/local/bin/php(php_execute_script+0x1fb)[0x6c3b4b]
/usr/local/bin/php[0x7f1024]
/usr/local/bin/php[0x7f18ad]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x7f28528d4cdd]
/usr/local/bin/php[0x4337a9]

cheers
Dan

Activity

  1. mkoppanen commented on Oct 28, 2013

    @mkoppanen
    Collaborator

    After quick debug this looks like ImageMagick bug.

  2. mkoppanen commented on Oct 30, 2013

    @mkoppanen
    Collaborator

    Reproduce code:

    #include <wand/MagickWand.h>
    #include <assert.h>
    
    int main ()
    {
        MagickBooleanType ret;
    
        MagickWand *wand = NewMagickWand ();
        assert (wand);
    
        ret = MagickReadImage (wand, "magick:rose");
        assert (ret == MagickTrue);
    
        ret = MagickSetImageFormat (wand, "jpg");
        assert (ret == MagickTrue);
    
        ret = MagickSetOption (wand, "jpeg:extent", "30kb");
        assert (ret == MagickTrue);
    
        size_t siz;
        unsigned char *rc = MagickGetImageBlob (wand, &siz);
        assert (rc);
    
        return 0;
    }
    

    Have you reported this upstream?

  3. Danack commented on Oct 31, 2013

    @Danack
    CollaboratorAuthor

    No, do you mind doing so? I think I've used up my quota of reporting things that aren't actually issues for the month.

    cheers
    Dan

  4. mkoppanen commented on Nov 4, 2013

    @mkoppanen
    Collaborator

    Seems like this will be fixed in ImageMagick 6.8.7-5 Beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions