php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21189 TTF output function frose Apache
Submitted: 2002-12-26 04:55 UTC Modified: 2003-01-27 22:29 UTC
Votes:8
Avg. Score:4.1 ± 1.1
Reproduced:8 of 8 (100.0%)
Same Version:4 (50.0%)
Same OS:5 (62.5%)
From: pvy at novosoft dot ru Assigned:
Status: No Feedback Package: GD related
PHP Version: 4.3.0RC4 OS: windows 2000/sp3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pvy at novosoft dot ru
New email:
PHP Version: OS:

 

 [2002-12-26 04:55 UTC] pvy at novosoft dot ru
Hello!
I made crash tests using WebRoller software.
I set to 10 requests my PHP code from 50 virtual clients simultaneously, and run 40 iterations.
I test php with php_gd.dll and php_gd2.dll.
in second case apache generates error on windows console (GPF)
I use next code:
<?php
    error_reporting(E_ALL);
	$img="tab100x25.png";
	header("content-Type: image/png");
	$text ="qwe";
    $textlen = strlen($text);
	$im = ImageCreateFromPng($img);
	$tab_color = ImageColorAllocate($im, 255, 255, 255);
	$txt_color = ImageColorAllocate($im, 0,0,0);
	$itSize=GetImageSize($img);
	$t_size = 11;
    ImageFill($im, 9 , 17, $tab_color);

  	ImageTTFText($im, $t_size, 0, 10, 10, $txt_color,
	    	"arial.ttf", $text);

	ImagePng($im);
	ImageDestroy($im);
?>


after crash test my system was frosen,apache haves 99% CPU and a lot of memory.
As next, I comment string  with ImageTTFText function and test it again.
Apache lives!
Below I will provide output from WebRollers test results:

Results from WebRoller with TTF function:
--- Start statistics ---

--- Basic statistics ---

Min:	50.00	20.00	30.00	50.00	70.00	60.00	30.00	30.00	
Avg:	514.82	602.53	785.38	827.82	378.96	238.82	200.40	199.07	
Max:	3270.00	4990.00	6350.00	7550.00	3410.00	2680.00	510.00	560.00	

--- Network traffic details ---

Total bytes sent     :    124242
Total bytes received :    347208
Average input speed  :      1152 bytes/sec

--- Summary times ---

Virtual Clients statistics:
Count	Time	AR/S	AT/R
100	1322442	0.08	13224.42
110	1290436	0.09	11731.24
101	1320349	0.08	13072.76
101	1320809	0.08	13077.32
114	1260793	0.09	11059.59
110	1262395	0.09	11476.32
99	1234395	0.08	12468.64
101	1293280	0.08	12804.75
101	1320759	0.08	13076.82
111	1263257	0.09	11380.69

Total work time:	1337293
Total requests made:	1048

Total average time per request:	1198.4126
Total average requests per second:	0.8344

--- Errors report ---

Total 425 errors!!!
Net :6
T/O :419


--- HTTP response codes details ---

Code	Count
200	629

--- End statistics ---

Results from WebRoller without TTF function:
--- Start statistics ---
--- Basic statistics ---

Min:	60.00	110.00	90.00	100.00	100.00	100.00	50.00	40.00	
Avg:	188.26	189.40	189.84	189.44	190.40	188.78	187.64	187.96	
Max:	240.00	280.00	310.00	330.00	290.00	260.00	270.00	280.00	

--- Network traffic details ---

Total bytes sent     :    475530
Average output speed : 475530000 bytes/sec
Total bytes received :   1844000
Average input speed  :      2382 bytes/sec

--- Summary times ---

Virtual Clients statistics:
Count	Time	AR/S	AT/R
400	78002	5.13	195.01
400	78052	5.12	195.13
400	77862	5.14	194.66
400	78162	5.12	195.41
400	78262	5.11	195.66
400	78202	5.11	195.51
400	78122	5.12	195.31
400	78202	5.11	195.51
400	78232	5.11	195.58
400	77942	5.13	194.85

Total work time:	78342
Total requests made:	4000

Total average time per request:	19.5948
Total average requests per second:	51.0341

--- HTTP response codes details ---

Code	Count
200	4000
--- End statistics ---


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-26 17:20 UTC] iliaa@php.net
Small note, TTF library is not thread safe, meaning that in Win32 enviroment it may not operate well.
 [2002-12-27 11:36 UTC] renaud dot boyer at helio-service dot fr
I have problems too, the same OS (Win2k sp3) with php_gd.dll and php_gd2.dll and php 4.2.3 & php 4.3.0RC4
php installed as an Apache 1.3.24 module
I use the gd only to produce small png, and i get error using imagettfbbox with this script:

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

$angle = 0;
$font_size = 11;
$font_file="font/arial.ttf";	
$taille=imagettfbbox(1, $angle, $font_file, $text);
$hauteur = 2*$font_size;
$largeur = abs($taille[0]-$taille[4]) + 1.5*$hauteur;

$img = imagecreate($largeur,$hauteur);
		 
$bleu = imagecolorallocate($img, 57, 50, 139	
$coul_texte = imagecolorallocate($img, 255, 255, 255);	

//text alignement...
if...
//returns $x_text and $y_text

imagettftext($img, $font_size, $angle, $x_text, $y_text, $coul_texte, $font_file, $text);
	
imagepng($img);
imagedestroy($img);
?>
---------

the results :

- php 4.2.3 with php_gd.dll
99% CPU used and a lot of ram, forced to stop apache service
nothing appears in the php error log.

- php 4.2.3 with php_gd2.dll
"Unable to find font" warning, with a relative link to the font or with an absolute link.
no image is drawn.

- php 4.3.0RC4 with php_gd.dll
99% CPU used and a lot of ram, forced to stop apache service
nothing appears in the php error log.

- php 4.3.0RC4 with php_gd2.dll
"Could not set character size" warning... Don't know why... And the strange thing is that sometimes the image is drawn, and sometimes not.

the script worked before on php 4.2.1, gd2, apache 1.3.?.
 [2003-01-27 22:29 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-12-16 12:31 UTC] dcrignon at adequasys dot com
I have the same kinf of problem under IIS5, W2K SP4, PHP 4.3.3

After multiple display, I've got this error on all GD images:

imagettfbbox(): Could not set character size

The first problem is that I usally have broken GD images. But if I do a right-click + Show image, it comes back.
And I don't know the reason of this problem...

Thanks for your help

We are also having problem under Apache/PHP4.3.3 under W2K...

So, is GD2 really stable ?

Thanks,

David

Here is my script :

<?
require("./../configuration/configuration.php");
$largeur_txt = 6;
$taille_txt = 7;

$fontfile = "c:\WINNT\FONTS\arial.ttf";

Header("Content-type: image/png");
$matrice = "./../images/".$couleur ."_" .$style .".png";
$lg_matrice_cote = 12;
$lg_matrice_centre = 10;

$string = stripslashes($text);

If (strlen($string) >= 2) {
	// size, angle, font file, text
	$tab = imagettfbbox($taille_txt,0,$fontfile,$string);
	$largeur_txt = $tab[2];
}

$lg = $largeur_txt + 26;
$ht = 17;
		
$lg_dst_milieu = $largeur_txt + 2;
$x_dst_d = $lg_dst_milieu + $lg_matrice_cote - 1;

$x_src_d = $lg_matrice_cote + $lg_matrice_centre;

$im_dst = imagecreate($lg,$ht);
$im_src = imagecreatefrompng($matrice);

imagecopyresized($im_dst, $im_src, 0, 0, 0, 0, $lg_matrice_cote, $ht, $lg_matrice_cote, $ht);

imagecopyresized($im_dst, $im_src, $lg_matrice_cote, 0, $lg_matrice_cote, 0, $lg_dst_milieu, $ht, $lg_matrice_centre, $ht);

imagecopyresized($im_dst, $im_src, $x_dst_d, 0, $x_src_d, 0, $lg_matrice_cote, $ht, $lg_matrice_cote, $ht);

$red = hexdec(substr($couleur_text,0,2));
$green = hexdec(substr($couleur_text,2,2));
$blue = hexdec(substr($couleur_text,4,2));

$couleur = ImageColorAllocate($im_dst, $red, $green, $blue);

if ($style == "l") {
   $px = $lg_matrice_cote + 3;
} else {
   $px = $lg_matrice_cote - 6;
}
if ($style == "b") {
   $py = $taille_txt + 4;
} else {
   $py = $taille_txt + 3;
}

imagettftext($im_dst,$taille_txt,0,$px,$py,$couleur,$fontfile,$string);
Imagepng($im_dst,'',100);
ImageDestroy($im_dst);
?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC