#23122 [Com]: ImageTTFText causes segmentation fault while under Apache

From: Date: Mon, 14 Apr 2003 16:11:50 +0000
Subject: #23122 [Com]: ImageTTFText causes segmentation fault while under Apache
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37650@lists.php.net to get a copy of this message
 ID:               23122
 Comment by:       gaugustu at csc dot com
 Reported By:      1413 at blargh dot com
 Status:           Open
 Bug Type:         GD related
 Operating System: Debian Linux
 PHP Version:      4.3.2RC1
 New Comment:

Have the same issue runnung on Solaris 9 sparc.
php4-STABLE-200304141530

Seems to be only on second call, i.e first run doesn't fault
(cache???)

let me know if I can be of further help.

 ./configure  --with-apxs2=/usr/local/httpd/bin/apxs --without-mysql
--prefix=/usr/local/httpd/php
--with-config-file-path=/usr/local/httpd/php --enable-track-vars
--enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext
--with-gdbm --with-ming --with-oci8 --with-xml --with-jpeg --with-png
--with-jpeg-dir=/usr/local/lib --enable-debug --enable-gd-native-ttf
--with-freetype-dir=/usr/local/lib --with-gd-dir=/usr/local/lib
--with-gd




bash-2.05# gdb httpd
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "sparc-sun-solaris2.9"...
(gdb) run -X
Starting program: /usr/local/httpd/bin/httpd -X
warning: Lowest section in /usr/lib/libintl.so.1 is .hash at 00000074
warning: Lowest section in /usr/lib/libintl.so.1 is .hash at 00000074
 
Program received signal SIGSEGV, Segmentation fault.
0xfec6f310 in fontTest (element=0x0, key=0xffbfe718)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/ext/gd/libgd/gdft.c:349
349       return (strcmp (a->fontlist, b->fontlist) == 0);
(gdb) bt
#0  0xfec6f310 in fontTest (element=0x0, key=0xffbfe718)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/ext/gd/libgd/gdft.c:349
#1  0xfec71f00 in gdCacheGet (head=0x251700, keydata=0xffbfe718)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/ext/gd/libgd/gdcache.c:104
#2  0xfec70b8c in gdImageStringFTEx (im=0x273bf0, brect=0xffbfe928,
fg=1,
    fontlist=0x26e0c8 "Times.ttf", ptsize=8, angle=0, x=10, y=13,
    string=0x270a30 "Monday 14th of April 2003", strex=0x0)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/ext/gd/libgd/gdft.c:825
#3  0xfec7093c in gdImageStringFT (im=0x273bf0, brect=0xffbfe928,
fg=1,
    fontlist=0x26e0c8 "Times.ttf", ptsize=8, angle=0, x=10, y=13,
    string=0x270a30 "Monday 14th of April 2003")
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/ext/gd/libgd/gdft.c:767
#4  0xfec580f4 in php_imagettftext_common (ht=8,
return_value=0x26e110,
    this_ptr=0x0, return_value_used=0, mode=0, extended=0)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/ext/gd/gd.c:3050
#5  0xfec57100 in zif_imagettftext (ht=8, return_value=0x26e110,
this_ptr=0x0,
    return_value_used=0)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/ext/gd/gd.c:2939
#6  0xfee1819c in execute (op_array=0x2737b8)
---Type <return> to continue, or q <return> to quit---
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/Zend/zend_execute.c:1606
#7  0xfedfe488 in zend_execute_scripts (type=8, retval=0x0,
file_count=3)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/Zend/zend.c:864
#8  0xfeda5d78 in php_execute_script (primary_file=0xffbff6d0)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/main/main.c:1636
#9  0xfee1fe70 in php_handler (r=0x26a940)
    at
/export/home/kcscga1/soft/php4-STABLE-200304141530/sapi/apache2handler/sapi_apache2.c:518
#10 0x0007a2c4 in ap_run_handler (r=0x26a940) at config.c:195
#11 0x0007a898 in ap_invoke_handler (r=0x26a940) at config.c:401
#12 0x000601e0 in ap_process_request (r=0x26a940) at
http_request.c:288
#13 0x0005b6f4 in ap_process_http_connection (c=0x260980) at
http_core.c:293
#14 0x00085624 in ap_run_process_connection (c=0x260980) at
connection.c:85
#15 0x00078ac8 in child_main (child_num_arg=2484552) at prefork.c:696
#16 0x00078cb8 in make_child (s=0x1b87a0, slot=0) at prefork.c:736
#17 0x00078d44 in startup_children (number_to_start=4) at
prefork.c:808
#18 0x00079574 in ap_mpm_run (_pconf=0x1, plog=0x1b3170, s=0x1b87a0)
    at prefork.c:1024
#19 0x0007f184 in main (argc=2, argv=0xffbffc4c) at main.c:660


Previous Comments:
------------------------------------------------------------------------

[2003-04-09 22:00:50] 1413 at blargh dot com

No - I converted the script to:

<?
/* Vertial Label maker */

$in = $_SERVER['argv'][1];

$im = ImageCreate(14,150);
$cBlack = ImageColorAllocate($im, 0, 0, 0);
$cWhite = ImageColorAllocate($im, 255, 255, 255);
$cBlue = ImageColorAllocate($im, 100, 100, 255);

ImageTTFText($im, 10, 90, 11, 150, $cWhite,
"/var/www/prime/common/arialbd.ttf", $in);

Header("Content-type: image/png");

ImagePng($im);

ImageDestroy($im);

?>

and tried it hundreds of times without getting a segfault.  When going
through Apache I get segfaults.

------------------------------------------------------------------------

[2003-04-09 21:16:14] iliaa@php.net

Can you replicate the problem using CLI sapi?

------------------------------------------------------------------------

[2003-04-08 19:52:58] 1413 at blargh dot com

Downloaded, compiled with same options as before, and 
installed.  Still crashes.  New GDB output follows. 
 
Starting program: /usr/sbin/apache -X 
(no debugging symbols found)...(no debugging symbols 
found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)... 
(no debugging symbols found)...(no debugging symbols 
found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)... 
(no debugging symbols found)...(no debugging symbols 
found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)... 
(no debugging symbols found)...(no debugging symbols 
found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)... 
(no debugging symbols found)...(no debugging symbols 
found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)... 
(no debugging symbols found)...(no debugging symbols 
found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)... 
Program received signal SIGSEGV, Segmentation fault. 
0x402b9c13 in fontTest (element=0x31, key=0xbfffd12c) at 
/root/php4-STABLE-200304082330/ext/gd/libgd/gdft.c:349 
349       return (strcmp (a->fontlist, b->fontlist) == 0); 
(gdb) bt 
#0  0x402b9c13 in fontTest (element=0x31, key=0xbfffd12c) 
at /root/php4-STABLE-200304082330/ext/gd/libgd/gdft.c:349 
#1  0x402bbb7e in gdCacheGet (head=0x8129210, 
keydata=0xbfffd12c) at 
/root/php4-STABLE-200304082330/ext/gd/libgd/gdcache.c:104 
#2  0x402bac80 in gdImageStringFTEx (im=0x8118d34, 
brect=0xbfffd2a0, fg=1, fontlist=0x811fd3c 
"/var/www/prime/common/arialbd.ttf", ptsize=10, 
angle=1.5707963267948966, x=11, y=150, string=0x810680c 
"Bonus 16-Mar-2003", 
    strex=0x0) at 
/root/php4-STABLE-200304082330/ext/gd/libgd/gdft.c:825 
#3  0x402baad4 in gdImageStringFT (im=0x8118d34, 
brect=0xbfffd2a0, fg=1, fontlist=0x811fd3c 
"/var/www/prime/common/arialbd.ttf", ptsize=10, 
angle=1.5707963267948966, x=11, y=150, string=0x810680c 
"Bonus 16-Mar-2003") 
    at 
/root/php4-STABLE-200304082330/ext/gd/libgd/gdft.c:767 
#4  0x402a8f7a in php_imagettftext_common (ht=8, 
return_value=0x811fd94, this_ptr=0x0, return_value_used=0, 
mode=0, extended=0) at 
/root/php4-STABLE-200304082330/ext/gd/gd.c:3050 
#5  0x402a8443 in zif_imagettftext (ht=8, 
return_value=0x811fd94, this_ptr=0x0, return_value_used=0) 
at /root/php4-STABLE-200304082330/ext/gd/gd.c:2939 
#6  0x403d2a52 in execute (op_array=0x810cb34) at 
/root/php4-STABLE-200304082330/Zend/zend_execute.c:1606 
#7  0x403bf8e4 in zend_execute_scripts (type=8, retval=0x0, 
file_count=3) at 
/root/php4-STABLE-200304082330/Zend/zend.c:864 
#8  0x4038465e in php_execute_script 
(primary_file=0xbffff9d8) at 
/root/php4-STABLE-200304082330/main/main.c:1653 
#9  0x403d7fd0 in apache_php_module_main (r=0x8101b2c, 
display_source_mode=0) at 
/root/php4-STABLE-200304082330/sapi/apache/sapi_apache.c:55 
#10 0x403d9080 in send_php (r=0x8101b2c, 
display_source_mode=0, filename=0x8103704 
"/var/www/prime/common/vl.php") at 
/root/php4-STABLE-200304082330/sapi/apache/mod_php4.c:617 
#11 0x403d90ff in send_parsed_php (r=0x8101b2c) at 
/root/php4-STABLE-200304082330/sapi/apache/mod_php4.c:632 
#12 0x08053ab4 in ap_invoke_handler () 
#13 0x0806342c in ap_some_auth_required () 
#14 0x08063488 in ap_process_request () 
#15 0x0805cc6b in ap_child_terminate () 
#16 0x0805cdfc in ap_child_terminate () 
#17 0x0805cf19 in ap_child_terminate () 
#18 0x0805d3f5 in ap_child_terminate () 
#19 0x0805dafd in main () 
#20 0x400f314f in __libc_start_main () from /lib/libc.so.6 
(gdb) print a 
$1 = (font_t *) 0x31 
(gdb) print b 
$2 = (fontkey_t *) 0xbfffd12c

------------------------------------------------------------------------

[2003-04-08 19:32:16] iliaa@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



------------------------------------------------------------------------

[2003-04-08 19:14:57] 1413 at blargh dot com

I have tried this with 4.3.2RC1 and the latest development 
snapshot.   
 
Configure options: 
./configure  --with-apxs --with-zlib --with-bz2 --with-gd 
--enable-gd-native-ttf --with-mysql=/usr --enable-sockets 
--prefix=/usr --with-ttf --enable-ftp --with-jpeg-dir=/usr 
--with-freetype-dir=/usr --enable-debug 
 
The following is the script that triggers the problem: 
 
<? 
 
/* Vertial Label maker */ 
$im = ImageCreate(14,150); 
$cBlack = ImageColorAllocate($im, 0, 0, 0); 
$cWhite = ImageColorAllocate($im, 255, 255, 255); 
$cBlue = ImageColorAllocate($im, 100, 100, 255); 
 
if($lk == 1) 
{ 
  ImageTTFText($im, 10, 90, 11, 150, $cBlue, 
"/var/www/prime/common/arialbd.ttf", $in); 
} else { 
  ImageTTFText($im, 10, 90, 11, 150, $cWhite, 
"/var/www/prime/common/arialbd.ttf", $in); 
} 
 
Header("Content-type: image/png"); 
 
ImagePng($im); 
 
ImageDestroy($im); 
 
?> 
 
This script is called a number of times in a page, with 
(for example): vl.php?lk=0&in=Bonus+30-Mar-2003 
 
Running gdb on apache -X, the crash occurs: 
 
Program received signal SIGSEGV, Segmentation fault. 
0x402b9c13 in fontTest (element=0x31, key=0xbfffd12c) at 
/root/php4-STABLE-200304082130/ext/gd/libgd/gdft.c:349 
349       return (strcmp (a->fontlist, b->fontlist) == 0); 
(gdb) bt 
#0  0x402b9c13 in fontTest (element=0x31, key=0xbfffd12c) 
at /root/php4-STABLE-200304082130/ext/gd/libgd/gdft.c:349 
#1  0x402bbb7e in gdCacheGet (head=0x8129210, 
keydata=0xbfffd12c) at 
/root/php4-STABLE-200304082130/ext/gd/libgd/gdcache.c:104 
#2  0x402bac80 in gdImageStringFTEx (im=0x8118d34, 
brect=0xbfffd2a0, fg=1, fontlist=0x811fd3c 
"/var/www/prime/common/arialbd.ttf", ptsize=10, 
angle=1.5707963267948966, x=11, y=150, string=0x810680c 
"Bonus 30-Mar-2003", 
    strex=0x0) at 
/root/php4-STABLE-200304082130/ext/gd/libgd/gdft.c:825 
#3  0x402baad4 in gdImageStringFT (im=0x8118d34, 
brect=0xbfffd2a0, fg=1, fontlist=0x811fd3c 
"/var/www/prime/common/arialbd.ttf", ptsize=10, 
angle=1.5707963267948966, x=11, y=150, string=0x810680c 
"Bonus 30-Mar-2003") 
    at 
/root/php4-STABLE-200304082130/ext/gd/libgd/gdft.c:767 
#4  0x402a8f7a in php_imagettftext_common (ht=8, 
return_value=0x811fd94, this_ptr=0x0, return_value_used=0, 
mode=0, extended=0) at 
/root/php4-STABLE-200304082130/ext/gd/gd.c:3050 
#5  0x402a8443 in zif_imagettftext (ht=8, 
return_value=0x811fd94, this_ptr=0x0, return_value_used=0) 
at /root/php4-STABLE-200304082130/ext/gd/gd.c:2939 
#6  0x403d2a52 in execute (op_array=0x810cb34) at 
/root/php4-STABLE-200304082130/Zend/zend_execute.c:1606 
#7  0x403bf8e4 in zend_execute_scripts (type=8, retval=0x0, 
file_count=3) at 
/root/php4-STABLE-200304082130/Zend/zend.c:864 
#8  0x4038465e in php_execute_script 
(primary_file=0xbffff9d8) at 
/root/php4-STABLE-200304082130/main/main.c:1653 
#9  0x403d7fd0 in apache_php_module_main (r=0x8101b2c, 
display_source_mode=0) at 
/root/php4-STABLE-200304082130/sapi/apache/sapi_apache.c:55 
#10 0x403d9080 in send_php (r=0x8101b2c, 
display_source_mode=0, filename=0x8103704 
"/var/www/prime/common/vl.php") at 
/root/php4-STABLE-200304082130/sapi/apache/mod_php4.c:617 
#11 0x403d90ff in send_parsed_php (r=0x8101b2c) at 
/root/php4-STABLE-200304082130/sapi/apache/mod_php4.c:632 
#12 0x08053ab4 in ap_invoke_handler () 
#13 0x0806342c in ap_some_auth_required () 
#14 0x08063488 in ap_process_request () 
#15 0x0805cc6b in ap_child_terminate () 
#16 0x0805cdfc in ap_child_terminate () 
#17 0x0805cf19 in ap_child_terminate () 
#18 0x0805d3f5 in ap_child_terminate () 
#19 0x0805dafd in main () 
#20 0x400f314f in __libc_start_main () from /lib/libc.so.6 
(gdb) print a 
$1 = (font_t *) 0x31 
(gdb) print b 
$2 = (fontkey_t *) 0xbfffd12c 
 

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=23122&edit=1



Thread (20 messages)

« previous php.bugs (#37650) next »