Discussion:
AppendImages () - Segmentation Fault
quanta
2011-02-24 15:42:42 UTC
Permalink
Hi,

I'm running ImageMagick 6.2.8.0-4 on CentOS 5.4.
PHP 5.3.2
Apache 2.2.3

Today, I got segfault error in the Apache logs:

Feb 24 13:35:21 SVR015-04 kernel: php[24679]: segfault at 0000000000000000 rip 0000003776ab45da rsp 00007fffc7266e40 error 6

Try to debug Apache with gdb, I got the following backtrace:

#0 0x00002af8f874a5da in AppendImages () from /usr/lib64/libMagick.so.10
#1 0x00002af8f84586ce in MagickAppendImages () from
/usr/lib64/libWand.so.10
#2 0x00002af8f81a3ad8 in zim_imagick_appendimages (ht=<value optimized
out>, return_value=0x2af8f9ded108,
return_value_ptr=<value optimized out>, this_ptr=<value optimized
out>, return_value_used=<value optimized out>)
at /var/tmp/imagick/imagick_class.c:8790
#3 0x00002af8f03fef29 in ?? () from /etc/httpd/modules/libphp5.so
#4 0x00002af8f03d544b in execute () from /etc/httpd/modules/libphp5.so
#5 0x00002af8f03b1ba5 in zend_execute_scripts () from
/etc/httpd/modules/libphp5.so
#6 0x00002af8f0362cc8 in php_execute_script () from
/etc/httpd/modules/libphp5.so
#7 0x00002af8f0439c2d in ?? () from /etc/httpd/modules/libphp5.so
#8 0x00002af8e8374a4a in ap_run_handler () from /usr/sbin/httpd
#9 0x00002af8e8377ec2 in ap_invoke_handler () from /usr/sbin/httpd
#10 0x00002af8e8382918 in ap_process_request () from /usr/sbin/httpd
#11 0x00002af8e837fb50 in ?? () from /usr/sbin/httpd

I also try to upgrade to lastest version of ImageMagick (install from binary):

# rpm -qa | grep ImageMagick
ImageMagick-devel-6.6.7-9
ImageMagick-6.6.7-9

but I got the below error when checking imagick extension (version 3.0.1) for PHP:

# php -m | grep imagick
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/imagick.so' - libMagick.so.10: cannot open shared object file: No such file or directory in Unknown on line 0

Making a symlink and it was loaded, but gdb still through a backtrace related to libMagick.so.10:

#0 0x00002b26ec86cb5a in ?? () from /usr/lib64/libMagick.so.10
#1 0x00002b26ed8b8f52 in ?? () from /usr/lib64/libgomp.so.1
#2 0x00002b26de01f4a7 in start_thread () from /lib64/libpthread.so.0
#3 0x00002b26de50cc2d in clone () from /lib64/libc.so.6

Any help will be appreciated.
quanta
2011-02-24 20:41:03 UTC
Permalink
I have compiled the lastest ImageMagick version from Subverion:

$ /usr/local/imagemagick/bin/convert -version
Version: ImageMagick 6.6.7-10 2011-02-24 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features:

I try to directly convert from command line with 2 images.
The strange thing is if I reverse the order I will got the segfault error:

$ gdb /usr/local/imagemagick/bin/convert
GNU gdb (Gentoo 7.2 p1) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /usr/local/imagemagick/bin/convert...done.
(gdb) run 2.jpg 1.jpg -append 21.jpg
Starting program: /usr/local/imagemagick/bin/convert 2.jpg 1.jpg -append
21.jpg
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0xb7cf3b14 in AppendImages (images=0x80707f0, stack=MagickTrue,
exception=0x804b588) at magick/image.c:551
551 append_indexes[x]=indexes[x];
(gdb) where
#0 0xb7cf3b14 in AppendImages (images=0x80707f0, stack=MagickTrue,
exception=0x804b588) at magick/image.c:551
#1 0xb7b84f7a in MogrifyImageList (image_info=0x8050130, argc=3,
argv=0x805423c, images=0xbfffdbd8, exception=0x804b588)
at wand/mogrify.c:7633
#2 0xb7b8e147 in MogrifyImages (image_info=0x8050130, post=MagickTrue,
argc=3, argv=0x805423c, images=0xbfffec78,
exception=0x804b588) at wand/mogrify.c:8570
#3 0xb7b07be1 in ConvertImageCommand (image_info=0x804b628, argc=5,
argv=0x8054238, metadata=0x0, exception=0x804b588)
at wand/convert.c:2953
#4 0xb7b868b8 in MagickCommandGenesis (image_info=0x804b628,
command=0x80488cc <***@plt>, argc=5,
argv=0xbfffef44, metadata=0x0, exception=0x804b588) at
wand/mogrify.c:169
#5 0x08048a6f in main (argc=5, argv=0xbfffef44) at utilities/convert.c:80

$ /usr/local/imagemagick/bin/convert -verbose 1.jpg 2.jpg -append 12.jpg
1.jpg JPEG 110x74 110x74+0+0 8-bit DirectClass 593KB 0.020u 0:00.019
2.jpg JPEG 110x74 110x74+0+0 8-bit DirectClass 33.2KB 0.000u 0:00.000
1.jpg=>12.jpg JPEG 110x74=>110x148 110x148+0+0 8-bit DirectClass 655KB
0.020u 0:00.330

I also post here the link to my images for you to try and investivate
the problem:

Loading Image...
Loading Image...
Post by quanta
Hi,
I'm running ImageMagick 6.2.8.0-4 on CentOS 5.4.
PHP 5.3.2
Apache 2.2.3
Feb 24 13:35:21 SVR015-04 kernel: php[24679]: segfault at 0000000000000000 rip 0000003776ab45da rsp 00007fffc7266e40 error 6
#0 0x00002af8f874a5da in AppendImages () from /usr/lib64/libMagick.so.10
#1 0x00002af8f84586ce in MagickAppendImages () from
/usr/lib64/libWand.so.10
#2 0x00002af8f81a3ad8 in zim_imagick_appendimages (ht=<value optimized
out>, return_value=0x2af8f9ded108,
return_value_ptr=<value optimized out>, this_ptr=<value optimized
out>, return_value_used=<value optimized out>)
at /var/tmp/imagick/imagick_class.c:8790
#3 0x00002af8f03fef29 in ?? () from /etc/httpd/modules/libphp5.so
#4 0x00002af8f03d544b in execute () from /etc/httpd/modules/libphp5.so
#5 0x00002af8f03b1ba5 in zend_execute_scripts () from
/etc/httpd/modules/libphp5.so
#6 0x00002af8f0362cc8 in php_execute_script () from
/etc/httpd/modules/libphp5.so
#7 0x00002af8f0439c2d in ?? () from /etc/httpd/modules/libphp5.so
#8 0x00002af8e8374a4a in ap_run_handler () from /usr/sbin/httpd
#9 0x00002af8e8377ec2 in ap_invoke_handler () from /usr/sbin/httpd
#10 0x00002af8e8382918 in ap_process_request () from /usr/sbin/httpd
#11 0x00002af8e837fb50 in ?? () from /usr/sbin/httpd
# rpm -qa | grep ImageMagick
ImageMagick-devel-6.6.7-9
ImageMagick-6.6.7-9
# php -m | grep imagick
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/imagick.so' - libMagick.so.10: cannot open shared object file: No such file or directory in Unknown on line 0
#0 0x00002b26ec86cb5a in ?? () from /usr/lib64/libMagick.so.10
#1 0x00002b26ed8b8f52 in ?? () from /usr/lib64/libgomp.so.1
#2 0x00002b26de01f4a7 in start_thread () from /lib64/libpthread.so.0
#3 0x00002b26de50cc2d in clone () from /lib64/libc.so.6
Any help will be appreciated.
quanta
2011-02-24 21:06:43 UTC
Permalink
On 02/24/2011 01:50 PM,
You need to rebuild / reinstall imagick so it matches the 6.6.7 version of
ImageMagick you just installed.
Yes, I did:

imagick

imagick module enabled
imagick module version 3.0.1
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.6.7-9 2011-02-22 Q16
http://www.imagemagick.org
ImageMagick copyright Copyright (C) 1999-2011 ImageMagick Studio LLC
ImageMagick release date 2011-02-22
ImageMagick number of supported formats: 189
ImageMagick supported formats 3FR, A, AAI, AI, ART, ARW, AVI, AVS, B,
BGR,
BGRA, BMP, BMP2, BMP3, BRF, C, CAL, CALS, CANVAS, CAPTION, CIN, CIP,
CLIP,
CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DNG, DOT,
DPX,
EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, ERF, FAX, FITS, FRACTAL, FTS,
G, G3,
GIF, GIF87, GRADIENT, GRAY, HALD, HISTOGRAM, HRZ, HTM, HTML, ICB,
ICO, ICON,
d***@imagemagick.org
2011-02-24 15:02:50 UTC
Permalink
Post by quanta
if I reverse the order I will got the segfault error
We can reproduce the problem you posted and have a patch in
ImageMagick 6.6.7-10 Beta available by sometime tomorrow. Thanks.
quanta
2011-02-24 22:17:23 UTC
Permalink
I'm looking forward to getting the patch from you because my Apache log
keeps throwing the segfault error.

PS: what does your email mean?

On 02/24/2011 03:02 PM,
Post by d***@imagemagick.org
Post by quanta
if I reverse the order I will got the segfault error
We can reproduce the problem you posted and have a patch in
ImageMagick 6.6.7-10 Beta available by sometime tomorrow. Thanks.
quanta
2011-04-28 08:27:01 UTC
Permalink
Hi,

I've upgraded ImageMagick to the latest version - 6.6.9-6 but I still
get the segfault:

#0 0x00002adadd90799a in AppendImages.omp_fn.7
(.omp_data_i=0x7fffdbea7010) at magick/image.c:551
#1 0x00002adadd90486e in AppendImages (images=<value optimized out>,
stack=MagickTrue, exception=0x2aaaaacaaef0)
at magick/image.c:412
#2 0x00002adadd55c4ae in MagickAppendImages (wand=0x2aaaaac00140,
stack=MagickTrue) at wand/magick-image.c:741
#3 0x00002adadd262aa8 in zim_imagick_appendimages (ht=<value optimized
out>, return_value=0x2adae8fc2080,
return_value_ptr=<value optimized out>, this_ptr=<value optimized
out>, return_value_used=<value optimized out>)
at /usr/local/src/imagick-3.1.0b1/imagick_class.c:8850
#4 0x00002adada0ef5c9 in ?? () from /etc/httpd/modules/libphp5.so
#5 0x00002adada0eeb2b in execute () from /etc/httpd/modules/libphp5.so
#6 0x00002adada0c80f5 in zend_execute_scripts () from
/etc/httpd/modules/libphp5.so
#7 0x00002adada078388 in php_execute_script () from
/etc/httpd/modules/libphp5.so
#8 0x00002adada150cbd in ?? () from /etc/httpd/modules/libphp5.so
#9 0x00002adacec29a4a in ap_run_handler ()
#10 0x00002adacec2ced8 in ap_invoke_handler ()
#11 0x00002adacec37938 in ap_process_request ()

I also tried with 2 versions of imagick extension: 3.0.1 and 3.1.0b1 but
not success.

Do you have any other ideas?

On 02/24/2011 10:02 PM,
Post by d***@imagemagick.org
Post by quanta
if I reverse the order I will got the segfault error
We can reproduce the problem you posted and have a patch in
ImageMagick 6.6.7-10 Beta available by sometime tomorrow. Thanks.
d***@imagemagick.org
2011-02-24 13:50:11 UTC
Permalink
Post by quanta
I also try to upgrade to lastest version of ImageMagick (install from binary)
Good, that is the recommended path forward when you encounter a bug. New
versions have lots of bug fixes.
Post by quanta
but I got the below error when checking imagick extension (version 3.0.1)
You need to rebuild / reinstall imagick so it matches the 6.6.7 version of
ImageMagick you just installed.
d***@imagemagick.org
2011-04-28 12:53:08 UTC
Permalink
We need to reproduce the problem. Can you send us a short script we can
use to cause the fault. Once we can reproduce it, we'll get you a patch to
fix the problem.

Thanks.
quanta
2011-04-29 03:10:05 UTC
Permalink
OK. I enclosed here 2 images which causes fault when append in order 1
to 3 (reverse the order works fine).

I use exiftool to view meta information from the images. It seems that
there is a problem with "Color Mode" and/or "Color Transform" in 3.jpg.

1.jpg:
Color Mode : RGB
Color Transform : YCbCr

3.jpg:
Color Mode : CMYK
Color Transform : YCCK

Thanks for your quick reply.

On 04/28/2011 07:53 PM,
Post by d***@imagemagick.org
We need to reproduce the problem. Can you send us a short script we can
use to cause the fault. Once we can reproduce it, we'll get you a patch to
fix the problem.
Thanks.
Loading...