imagettfbbox call causes Apache segfault
Description
We faced the segfault issue after we upgraded to php 8.1. The segfault happens only when imagettfbbox is called under Apache. We were unable to reproduce this issue in cli. Problem occurs occasionally. When imagettfbbox is called, one of the following happens:
- php warning: imagettfbbox(): Problem loading glyph in ...
- correct result
- segfault
We use httpd 2.4.6.
Code which produces the issue
<?php
$font = './Lobster.ttf';
$fontsize = 24;
$text = 'walle';
$mas1 = imagettfbbox($fontsize, 0, $font, $nick1);
gdb core dump
Thread 1 (Thread 0x7f7f27bd7880 (LWP 1062)):
#0 0x00007f7f0d400ddd in gdImageStringFTEx () from /lib64/libgd.so.103
No symbol table info available.
#1 0x00007f7f0d401c5b in gdImageStringFT () from /lib64/libgd.so.103
No symbol table info available.
#2 0x00007f7f27a28390 in php_imagettftext_common.isra.0 () from /usr/lib64/php/modules/gd.so
No symbol table info available.
#3 0x00007f7f1aad7402 in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#4 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
No symbol table info available.
#5 0x00007f7f1a9a04df in zif_call_user_func_array () from /etc/httpd/modules/libphp.so
No symbol table info available.
#6 0x00007f7f1aada63a in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#7 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
No symbol table info available.
#8 0x00007f7f1a9a04df in zif_call_user_func_array () from /etc/httpd/modules/libphp.so
No symbol table info available.
#9 0x00007f7f1aada63a in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#10 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
No symbol table info available.
#11 0x00007f7f1a9a04df in zif_call_user_func_array () from /etc/httpd/modules/libphp.so
No symbol table info available.
#12 0x00007f7f1aada63a in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#13 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
No symbol table info available.
#14 0x00007f7f1a9a04df in zif_call_user_func_array () from /etc/httpd/modules/libphp.so
No symbol table info available.
#15 0x00007f7f1aada63a in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#16 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
No symbol table info available.
#17 0x00007f7f1a9a04df in zif_call_user_func_array () from /etc/httpd/modules/libphp.so
No symbol table info available.
#18 0x00007f7f1aada63a in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#19 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
No symbol table info available.
#20 0x00007f7f1a9a04df in zif_call_user_func_array () from /etc/httpd/modules/libphp.so
No symbol table info available.
#21 0x00007f7f1aada63a in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#22 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
No symbol table info available.
#23 0x00007f7f1a9a04df in zif_call_user_func_array () from /etc/httpd/modules/libphp.so
No symbol table info available.
#24 0x00007f7f1aada63a in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#25 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
No symbol table info available.
#26 0x00007f7f1a9a04df in zif_call_user_func_array () from /etc/httpd/modules/libphp.so
No symbol table info available.
#27 0x00007f7f1aada63a in execute_ex () from /etc/httpd/modules/libphp.so
No symbol table info available.
#28 0x00007f7f1aa61e24 in zend_call_function () from /etc/httpd/modules/libphp.so
PHP Version
PHP 8.1.2
Operating System
CentOS 7
Thanks for the backtrace. So the faulting line is https://github.com/libgd/libgd/blob/gd-2.3.3/src/gdft.c#L1400. Is the libgd you are using built with libraqm support?
Is the libgd you are using built with libraqm support?
Yes. Looks like you a right about libraqm. We updated it and install libraqm-devel package. The issue disappeared. At least we don't observe any warnings or segfault now.
We have to conduct several tests in order to check that gd provides expected results. I'll return with results. Thx!
Ah, good news! I'm switching back to "Needs Feedback" (that will automatically close the ticket in 2 weeks; you can still re-open if it takes longer to evaluate the results with the update).
We performed several tests. Everything works fine. Many thanks for your help and time!