php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25146 Crashed intermittantly when getting the bounding box
Submitted: 2003-08-19 07:27 UTC Modified: 2003-08-19 09:00 UTC
From: mmusone at shatterit dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.3.2 OS: Linux (Redhat 9)
Private report: No CVE-ID: None
 [2003-08-19 07:27 UTC] mmusone at shatterit dot com
Description:
------------
I am having intermittant but frequent crashes (not all the time, but about 3 out of every 5 page loads)
when using either imageftbbox OR imagettfbbox.
Below is a sample code snippet that i can use to reproduce the crash.

Note, this is using apache2. I am unable to reproduce this crash when trying to run it from the command line. it only seems to happen via the browser/apache

Note also, that i tried out two system installed fonts, and both of them caused the same problem. I have not tried additional fonts.

PHP configure Line:

'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql' '--with-gd=/usr/local' '--with-zlib-dir=/usr/lib' '--with-freetype-dir' '--with-ttf' 

Gd Details (installed the most recent 2.0.15 GD)

gd
GD Support  enabled  
GD Version  2.0 or higher  
FreeType Support  enabled  
FreeType Linkage  with freetype  
JPG Support  enabled  
PNG Support  enabled  
WBMP Support  enabled  



Reproduce code:
---------------
<?
$fontfile="/usr/share/fonts/local/arial.ttf";
$fontfile="/usr/X11R6/lib/X11/fonts/TTF/luximr.ttf";

$bbox = imageftbbox(10, 0, $fontfile, "50",array());

print_r($bbox);
?>


Expected result:
----------------
Array
(
    [0] => 0
    [1] => -1
    [2] => 15
    [3] => -1
    [4] => 15
    [5] => -11
    [6] => 0
    [7] => -11
)


Actual result:
--------------
Starting program: /usr/local/apache2/bin/httpd -X -k start
[New Thread 1075570272 (LWP 4630)]
httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1075570272 (LWP 4630)]
fontTest (element=0x20, key=0x20) at gdft.c:337
337       return (strcmp (a->fontlist, b->fontlist) == 0);
(gdb) where
#0  fontTest (element=0x20, key=0x20) at gdft.c:337
#1  0x40311b13 in gdCacheGet (head=0x817db00, keydata=0xbfffbc58) at gdcache.c:108
#2  0x4031284d in gdImageStringFTEx (im=0x0, brect=0xbfffbd40, fg=-1, fontlist=0x20 <Address 0x20 out of bounds>,
    ptsize=10, angle=0, x=-1, y=-1, string=0x817d25c "50", strex=0xbfffbd30) at gdft.c:856
#3  0x401f55ca in php_imagettftext_common (ht=135781120, return_value=0x817cc84, this_ptr=0x0, return_value_used=1, mode=1,
    extended=1) at /usr/local/src/php-4.3.2/ext/gd/gd.c:3052
#4  0x401f5173 in zif_imageftbbox (ht=5, return_value=0x817cc84, this_ptr=0x0, return_value_used=1)
    at /usr/local/src/php-4.3.2/ext/gd/gd.c:2921
#5  0x402b5d62 in execute (op_array=0x8182fd4) at /usr/local/src/php-4.3.2/Zend/zend_execute.c:1606
#6  0x402a95fd in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/local/src/php-4.3.2/Zend/zend.c:869
#7  0x402842eb in php_execute_script (primary_file=0xbfffe270) at /usr/local/src/php-4.3.2/main/main.c:1671
#8  0x402ba348 in php_handler (r=0x818bd58) at /usr/local/src/php-4.3.2/sapi/apache2handler/sapi_apache2.c:525
#9  0x0807b952 in ap_run_handler (r=0x818bd58) at config.c:195
#10 0x0807be6a in ap_invoke_handler (r=0x818bd58) at config.c:401
#11 0x0806bc73 in ap_process_request (r=0x818bd58) at http_request.c:288
#12 0x08067ec1 in ap_process_http_connection (c=0x816d1a0) at http_core.c:293
#13 0x0808474a in ap_run_process_connection (c=0x816d1a0) at connection.c:85
#14 0x0807a513 in child_main (child_num_arg=32) at prefork.c:694
#15 0x0807a6be in make_child (s=0x80b5ed8, slot=0) at prefork.c:734
#16 0x0807a717 in startup_children (number_to_start=5) at prefork.c:806
#17 0x0807adfd in ap_mpm_run (_pconf=0x8079dfc, plog=0x80eb8b0, s=0x80b5ed8) at prefork.c:1022
#18 0x0807fb16 in main (argc=4, argv=0xbfffe524) at main.c:660
#19 0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6
(gdb) quit


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-19 07:31 UTC] derick@php.net
Which Apache 2 MPM are you using?
 [2003-08-19 07:38 UTC] mmusone at shatterit dot com
Prefork ?? Is this what you are looking for:


[root@warehouse php-4.3.2]# /usr/local/apache2/bin/httpd -V
Server version: Apache/2.0.47
Server built:   Aug 17 2003 11:17:41
Server's Module Magic Number: 20020903:4
Architecture:   32-bit
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_PROC_PTHREAD_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
 [2003-08-19 08:17 UTC] mmusone at shatterit dot com
I just downgraded to apache 1.3.28, and the crashes are still occuring.

Below is a backtrace:

(gdb) run -X
Starting program: /usr/local/apache/bin/httpd -X
[Tue Aug 19 09:10:57 2003] [alert] httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Program received signal SIGSEGV, Segmentation fault.
fontTest (element=0x20, key=0x20) at gdft.c:337
337       return (strcmp (a->fontlist, b->fontlist) == 0);
(gdb) where
#0  fontTest (element=0x20, key=0x20) at gdft.c:337
#1  0x401fbb13 in gdCacheGet (head=0x8104940, keydata=0xbfffbac8) at gdcache.c:108
#2  0x401fc84d in gdImageStringFTEx (im=0x0, brect=0xbfffbbb0, fg=-1,
    fontlist=0x20 <Address 0x20 out of bounds>, ptsize=10, angle=0, x=-1, y=-1, string=0x80fc2e4 "50",
    strex=0xbfffbba0) at gdft.c:856
#3  0x400df4d2 in php_imagettftext_common (ht=135285056, return_value=0x80fcda4, this_ptr=0x0,
    return_value_used=1, mode=1, extended=1) at /usr/local/src/php-4.3.2/ext/gd/gd.c:3052
#4  0x400df07b in zif_imageftbbox (ht=5, return_value=0x80fcda4, this_ptr=0x0, return_value_used=1)
    at /usr/local/src/php-4.3.2/ext/gd/gd.c:2921
#5  0x4019fc6a in execute (op_array=0x80fcaac) at /usr/local/src/php-4.3.2/Zend/zend_execute.c:1606
#6  0x40193505 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /usr/local/src/php-4.3.2/Zend/zend.c:869
#7  0x4016e1f3 in php_execute_script (primary_file=0xbfffe190)
    at /usr/local/src/php-4.3.2/main/main.c:1671
#8  0x401a38c2 in apache_php_module_main (r=0x80f9fdc, display_source_mode=0)
    at /usr/local/src/php-4.3.2/sapi/apache/sapi_apache.c:54
#9  0x401a42d5 in send_php (r=0x80f9fdc, display_source_mode=0, filename=0x0)
    at /usr/local/src/php-4.3.2/sapi/apache/mod_php4.c:617
#10 0x401a446a in send_parsed_php (r=0x80f9fdc) at /usr/local/src/php-4.3.2/sapi/apache/mod_php4.c:632
#11 0x08069e8b in ap_invoke_handler ()
#12 0x0807e78e in process_request_internal ()
#13 0x0807e7ed in ap_process_request ()
#14 0x08075a5e in child_main ()
#15 0x08075bfe in make_child ()
#16 0x08075d64 in startup_children ()
#17 0x08076401 in standalone_main ()
#18 0x08076c1f in main ()
#19 0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6
 [2003-08-19 08:55 UTC] mmusone at shatterit dot com
I think i fixed it...using the built-in GD library does not seme to crash.

compiling in the external Gd library, 2.0.15 seems to be causing it to crash.

I also tried the latest PHP CVs snapshot, and it also crashed with using the external GD library.
 [2003-08-19 09:00 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Use the bundled library it is tested and known to work. As for why the external library crashes, that already something up to the GD library developers to determine.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Feb 19 04:00:01 2026 UTC