Topic: Imagemagick segfault

ImageMagick6-6.9.10.68 or perhaps php-pecl-imagick-3.4.4 on centos77 is segfaulting with annotateImage() function. I was just testing with a simple test script

<?php 
/* Create some objects */
$image = new Imagick(); 
$draw = new ImagickDraw(); 
$pixel = new ImagickPixel('white'); 

/* New image */
$image->newImage(800, 300, $pixel); 

/* Black text */
$draw->setFillColor('green'); 

/* Font properties */
$draw->setFontSize( 30 ); 

/* Create text */
$image->annotateImage($draw, 30, 140, 0, 'GeeksforGeeks: A computer science portal'); 

/* Give image a format */
$image->setImageFormat('png'); 

/* Output the image with headers */
header('Content-type: image/png'); 
echo $image; 
?> 

No segfault with the annotate line commented out. Here's the gdb backtrace

(gdb) bt
#0  GetNextUTFCode (octets=<synthetic pointer>, text=0x55565600bce0 <Address 0x55565600bce0 out of bounds>)
    at magick/token-private.h:110
#1  GetUTFCode (text=0x55565600bcdf <Address 0x55565600bcdf out of bounds>) at magick/token-private.h:138
#2  RenderFreetype (image=image@entry=0x555555fdd8b0, draw_info=draw_info@entry=0x555556013db0, encoding=<optimized out>, 
    offset=offset@entry=0x7fffffff7ab0, metrics=metrics@entry=0x7fffffff7bb0) at magick/annotate.c:1730
#3  0x00007fffe0e6d500 in RenderType (image=image@entry=0x555555fdd8b0, draw_info=draw_info@entry=0x555555fe4010, 
    offset=offset@entry=0x7fffffff7ab0, metrics=metrics@entry=0x7fffffff7bb0) at magick/annotate.c:974
#4  0x00007fffe0e6d9d7 in GetTypeMetrics (image=image@entry=0x555555fdd8b0, draw_info=draw_info@entry=0x555555fe3990, 
    metrics=metrics@entry=0x7fffffff7bb0) at magick/annotate.c:830
#5  0x00007fffe0e6df2c in AnnotateImage (image=0x555555fdd8b0, draw_info=draw_info@entry=0x555555fe3650)
    at magick/annotate.c:326
#6  0x00007fffe1386baa in MagickAnnotateImage (wand=0x555555fb3140, drawing_wand=<optimized out>, x=10, y=45, angle=0, 
    text=<optimized out>) at wand/magick-image.c:671
#7  0x00007fffe1656d05 in zim_imagick_annotateimage (execute_data=<optimized out>, return_value=0x7fffffffad90)
    at /usr/src/debug/php-pecl-imagick-3.4.4/NTS/imagick_class.c:10059
#8  0x00005555558e5eb9 in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER () at /usr/src/debug/php-7.2.23/Zend/zend_vm_execute.h:911
#9  execute_ex (ex=0x55565600bcdf) at /usr/src/debug/php-7.2.23/Zend/zend_vm_execute.h:59769
#10 0x00005555558e621e in zend_execute (op_array=op_array@entry=0x7ffff387d2a0, return_value=return_value@entry=0x7ffff3877360)
    at /usr/src/debug/php-7.2.23/Zend/zend_vm_execute.h:63780
#11 0x0000555555833a83 in zend_execute_scripts (type=-209596368, type@entry=8, retval=0x7ffff3877360, retval@entry=0x0, 
    file_count=file_count@entry=3) at /usr/src/debug/php-7.2.23/Zend/zend.c:1498
#12 0x00005555557ce1e8 in php_execute_script (primary_file=primary_file@entry=0x7fffffffd390)
    at /usr/src/debug/php-7.2.23/main/main.c:2599
#13 0x00005555558e85ef in do_cli (argc=2, argv=0x555555c76a90) at /usr/src/debug/php-7.2.23/sapi/cli/php_cli.c:1011
#14 0x000055555563ddab in main (argc=2, argv=0x555555c76a90) at /usr/src/debug/php-7.2.23/sapi/cli/php_cli.c:1403

Re: Imagemagick segfault

Sorry, cannot reproduce on a fully updated CentOS 7.7 VM

FYI: each build of IM runs the upstream test suite and I also run pecl/imagick test suite with resulting RPM.
Only pushed to the repository if both are ok

Please check "yum update" first

Can be related to a missing font ?

Perhaps worth an upstream report.

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: Imagemagick segfault

Figured it out. Had an older version of libraqm installed. Updated to latest and issue gone.

Re: Imagemagick segfault

indeed, have been recently updated to 0.7 in EPEL
and cherry-pick update cannot be supported.

Thanks for the feedback about the fix.

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test