php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23035 PHP has encountered an Access Violation at 0144B261
Submitted: 2003-04-03 08:37 UTC Modified: 2003-04-22 03:14 UTC
From: richard dot quadling at carval dot co dot uk Assigned:
Status: Closed Package: GD related
PHP Version: 4.3.1 OS: Windows 2000
Private report: No CVE-ID: None
 [2003-04-03 08:37 UTC] richard dot quadling at carval dot co dot uk
I am using Sambar Server V5.4 Production as a webserver and getting ...

[2003-04-03 14:58:12] PHP4ISAPI.DLL: WriteClient(51 bytes) PHP has encountered an Access Violation at 0144B261

in the ISAPI.LOG file (with logging set to full).

This is the complete entry.

[2003-04-03 14:57:34] Loading PHP4ISAPI.DLL: isapi
[2003-04-03 14:58:01] PHP4ISAPI.DLL: Run for 10.0.0.24
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'HTTP_COOKIE' returned: Balls=38%6044%6032%6047%6023%6031%6043
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'ALL_HTTP' returned: HTTP_CONNECTION:Keep-Alive
HTTP_ACCEPT_LANGUAGE:en-gb
HTTP_HOST:richard-dev.pfl
HTTP_ACCEPT:image/gi
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'HTTPS' returned: off
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'SCRIPT_NAME' returned: /ttf.php
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'AUTH_PASSWORD' returned: 
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'AUTH_TYPE' returned: 
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'AUTH_USER' returned: 
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'CONTENT_LENGTH' returned: 0
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'CONTENT_TYPE' returned: 
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'PATH_TRANSLATED' returned: C:/Personal/WebSites/PFL/public_html/ttf.php
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'QUERY_STRING' returned: 
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'REMOTE_ADDR' returned: 10.0.0.24
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'REMOTE_HOST' returned: 10.0.0.24
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'REMOTE_USER' returned: 
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'REQUEST_METHOD' returned: GET
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'SERVER_NAME' returned: richard-dev.pfl
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'SERVER_PORT' returned: 80
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'SERVER_PROTOCOL' returned: HTTP/1.1
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'SERVER_SOFTWARE' returned: SAMBAR
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'APPL_MD_PATH' not found
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'APPL_PHYSICAL_PATH' not found
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'INSTANCE_ID' not found
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'INSTANCE_META_PATH' not found
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'LOGON_USER' returned: 
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'REQUEST_URI' returned: /ttf.php
[2003-04-03 14:58:01] PHP4ISAPI.DLL: GetServerVariable 'URL' returned: /ttf.php
[2003-04-03 14:58:01] PHP4ISAPI.DLL: ServerFunc()  HSE_REQ_MAP_URL_TO_PATH_EX '/'
[2003-04-03 14:58:12] PHP4ISAPI.DLL: ServerFunc()  HSE_REQ_SEND_RESPONSE_HEADER_EX '500 Internal Server Error'
[2003-04-03 14:58:12] PHP4ISAPI.DLL: WriteClient(51 bytes) PHP has encountered an Access Violation at 0144B261
[2003-04-03 14:58:12] PHP4ISAPI.DLL: WriteClient(433 bytes) ?
[2003-04-03 14:58:12] PHP4ISAPI.DLL: Returned HSE_STATUS_SUCCESS

The code generating this error is a small program to produce thumbnails of the fonts installed in my C:\winnt\fonts directory.

If I hardcode the exclusion of particular fonts, then the program will work as expected.

The font names are SYMBOL, MARLETT, OUTLOOK, WINGDING, WEBDINGS, WEBDNGS2, WEBDNGS3.

These are all symbol fonts.

BUT. If I ONLY tell it to deal with MARLETT.TTF then the code seems to work without a problem.

My script for all of this is ...

<?php
error_reporting(E_ALL);

// Allow a debug log to be produced.
$bDebug = False;

// Where are the fonts?
$sFontDir = 'C:/WINNT/FONTS';

// A function to create the PNG file for the supplied font.
function MakePNG ($sFontDir,$sFontName)
{
global $fp;

// What text to show in the PNG.
$aTexts = array(
	 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
	 'abcdefghijklmnopqrstuvwxyz',
	 '1234567890',
	 'The quick brown fox jumps over the lazy dog.',
	 'The big jackdaws love my sphinx of quartz.'
	 );

// What height and width should I make?
$aDim = array ('Width' => 0, 'Height' => 0);

// Font size.
$iFontSize = 12;

// Get the dimensions for each of the strings.
foreach ($aTexts as $v)
	{
	if ($bDebug) { fputs($fp, "About to : \$aSizes = ImageTTFBBox ($iFontSize,0,\"$sFontDir/$sFontName\",\"$v\");<br>\n"); }
	$aSizes = ImageTTFBBox ($iFontSize,0,"$sFontDir/$sFontName","$v");
	if ($bDebug) { fputs($fp, "Complete : \$aSizes = ImageTTFBBox ($iFontSize,0,\"$sFontDir/$sFontName\",\"$v\");<br>\n\n"); }

// Work out the biggest so far.
	$aDim['Width'] = max ($aDim['Width'], 5 + ($aSizes[2] - $aSizes[0]) );
	$aDim['Height'] = max ($aDim['Height'], 5 + abs($aSizes[7] - $aSizes[1]) );
	}

// Create the blank image to the correct size.
if ($bDebug) { fputs($fp, "About to : \$gImage = ImageCreate (\$aDim['Width'] + 6, (3 + \$aDim['Height']) * count (\$aTexts) );<br>\n"); }
$gImage = ImageCreate ($aDim['Width'] + 6, (3 + $aDim['Height']) * count ($aTexts) );
if ($bDebug) { fputs($fp, "Complete : \$gImage = ImageCreate (\$aDim['Width'] + 6, (3 + \$aDim['Height']) * count (\$aTexts) );<br>\n\n"); }

// Set up the background colour.
if ($bDebug) { fputs($fp, "About to : \$gcolBackground = ImageColorAllocate (\$gImage, 255, 255, 255);<br>\n"); }
$gcolBackground = ImageColorAllocate ($gImage, 255, 255, 255);
if ($bDebug) { fputs($fp, "Complete : \$gcolBackground = ImageColorAllocate (\$gImage, 255, 255, 255);<br>\n\n"); }

// Set up the font colour.
if ($bDebug) { fputs($fp, "About to : \$gcolFont = ImageColorAllocate (\$gImage, 0, 0, 0);<br>\n"); }
$gcolFont = ImageColorAllocate ($gImage, 0, 0, 0);
if ($bDebug) { fputs($fp, "Complete : \$gcolFont = ImageColorAllocate (\$gImage, 0, 0, 0);<br>\n\n"); }

// Add the texts into the image.
foreach ($aTexts as $k => $v)
	{
	if ($bDebug) { fputs($fp, "About to : ImageTTFText (\$gImage, \$iFontSize, 0, 5, \$aDim['Height'] * ($k + 1), \$gcolFont, \"$sFontDir/$sFontName\", \"$v\");<br>\n"); }
	ImageTTFText ($gImage, $iFontSize, 0, 5, $aDim['Height'] * ($k + 1), $gcolFont, "$sFontDir/$sFontName", "$v");
	if ($bDebug) { fputs($fp, "Complete : ImageTTFText (\$gImage, \$iFontSize, 0, 5, \$aDim['Height'] * ($k + 1), \$gcolFont, \"$sFontDir/$sFontName\", \"$v\");<br>\n\n"); }
	}

// Save the image.
if ($bDebug) { fputs($fp, "About to : Imagepng (\$gImage,\"./pngs/$sFontName.png\");<br>\n"); }
Imagepng ($gImage,"./pngs/$sFontName.png");
if ($bDebug) { fputs($fp, "Complete : Imagepng (\$gImage,\"./pngs/$sFontName.png\");<br>\n\n"); }

// Destroy the image.
if ($bDebug) { fputs($fp, "About to : ImageDestroy (\$gImage);<br>\n"); }
ImageDestroy ($gImage);
if ($bDebug) { fputs($fp, "Complete : ImageDestroy (\$gImage);<br>\n\n"); }
}

// Build the page of fonts and images.
echo '<html><head><title>Fonts</title></head><body>';
$aFiles[0] = glob("$sFontDir/*.ttf");
$aFiles[1] = glob("$sFontDir/*.TTF");
$aFonts = array_merge($aFiles[0],$aFiles[1]);
natcasesort($aFonts);
if ($bDebug) { $fp = fopen('./log.txt','wt'); }
foreach ($aFonts as $sFont)
	{
	$sFont = strtoupper(end(explode('/',$sFont)));
// Allow for the exclusion of nasty fonts.
	if ((!$bDebug) && ($sFont != 'MARLETT.TTF') && ($sFont != 'OUTLOOK.TTF') && ($sFont != 'SYMBOL.TTF') && ($sFont != 'WEBDINGS.TTF') && ($sFont != 'WINGDING.TTF'))
		{
		MakePNG($sFontDir,$sFont);
		echo "$sFont<br><img src=\"./pngs/$sFont.png\"><br>";
		}
	}
echo '</body></html>';
if ($bDebug) { fclose($fp); }
?>

Altering the $bDebug flag will toggle the logging.

The line with the font names in can be commented out to show the error.

Regards,

Richard Quadling.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-03 12:25 UTC] sniper@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


And can you please shorten the example script to
max. 10-15 lines.


 [2003-04-04 04:01 UTC] richard dot quadling at carval dot co dot uk
Ok.

The line which causes the program to crash does NOT make it crash when used by itself.

e.g.

This script works ...

<?php
error_reporting(E_ALL);

$aSizes = ImageTTFBBox (12,0,"C:/WINNT/FONTS/MARLETT.TTF","ABCDEFGHIJKLMNOPQRSTUVWXYZ");
echo "<pre>";
print_r($aSizes);
echo "</pre>";
?>

The ImageTTFBBox() function is the call that causes the AV error when used with the Marlett TTF font within the long loop.

I am now retrying both tests with the snapshot supplied.
 [2003-04-09 21:20 UTC] iliaa@php.net
If the problem persists, please provide a URL to where the font used in the script can be downloaded from.
 [2003-04-21 09:20 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-04-22 03:14 UTC] richard dot quadling at carval dot co dot uk
I am no longer getting this error.

I am still getting inconsistent results though, but not a crash.

I'll keep trying with the snapshots.

If I can determine a repeatable issue, I will re-report.

Regards,

Richard Quadling.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 15:01:33 2024 UTC