php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14222 PHP Crashes with weird output often
Submitted: 2001-11-26 02:37 UTC Modified: 2002-06-18 19:01 UTC
Votes:16
Avg. Score:4.9 ± 0.3
Reproduced:14 of 14 (100.0%)
Same Version:11 (78.6%)
Same OS:13 (92.9%)
From: mail at seen dot ch Assigned:
Status: Closed Package: Apache related
PHP Version: 4.1.1 OS: Windows XP Pro
Private report: No CVE-ID: None
 [2001-11-26 02:37 UTC] mail at seen dot ch
Its like the Bug id #13371, just i found the same thing with Apache 1.3.22.

Installed:
Apache 1.3.22
PHP 4.0.6 (both, full and installer make problems)
MySQL 4.0.0a
on a Win XP En Machine.
PHP used with php4apache.dll

Very weird things:
Some code dont work, some work fine.
Ex.: phpMyAdmin dont have any problems

Code Example:

//////////////////////////////////////
//Start of Code Example
//////////////////////////////////////

<html>
<head>
<?php
//Funktion f&uuml;r DB Errors
function print_db_error($query) {
	$errno=addslashes(mysql_errno());
	$error=addslashes(mysql_error());
	echo $query."<br>liefert folgende Fehlermeldung:<br>".$errno.$error;
}
//Login
function login($uin){
	if($uin == "xxx") return 1;
};
//simple abfrage (1 user)
if($HTTP_POST_VARS[submit]==go){
	if($username==xxx AND $password==xxx)
		$uin = "xxx";
};

//$loggedin = login($uin);
$loggedin = 1;

//Funktion f&uuml;r MySQL querys
function sql($query){
	$hostname = "dedi.gamelife.ch"; 
	$db_username = "xxx"; 
	$password = "xxx";
	$dbName1 = 'xxx';
	$conn = mysql_pconnect($hostname, $db_username, $password);
	if(!$conn){
		echo "<B>Oops, der Datenbankserver hat wohl die Hosen runtergelassen!";
		exit;
	};
	$select = mysql_select_db($dbName1,$conn);
	$abfrage=mysql_query($query, $conn) 
		or 
	print_db_error($query);
	
	return $abfrage;
};

//Tables
$tbl_list = priv_divxlist;
//Update the instore
if($action=="changestore"){
	(mysql_result(sql("SELECT instore FROM $tbl_list WHERE id='$id'"),0)) ? 
		$newstore = "0" : $newstore = "1";
		sql("UPDATE $tbl_list SET instore='$newstore' WHERE id='$id'");
};

//Default: sortby name
if(!isset($sortby))
	$sortby = "titel asc";
?>
</head>
	<body bgcolor="#FFFFFF" text="#000000" link="#829DD2" vlink="#829DD2">
	   	<font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<? if(!$loggedin){?>
		<form action="<?=$PHP_SELF?>?sortby=<?=$sortby?>" method=post>
		Login: <input type="text" name="username" size="5"> <input type="password" name="password" size="5"> <input type="submit" name="submit" value="go"></form>
<? }else{ ?>
		<a href="newp.htm">Create new Item</a><br>
<? }; ?>
		<br>
		<table border=0 cellpadding="0" cellspacing="0">
			<tr>
				<td><font size=2><a href="<?=$PHP_SELF?>?sortby=<? echo ($sortby=="titel desc") ? "titel asc" : "titel desc"; ?>&uin=<?=$uin?>">Titel</a></font><br><br></td>
				<td><font size=2><a href="<?=$PHP_SELF?>?sortby=<? echo ($sortby=="lang desc") ? "lang asc" : "lang desc"; ?>&uin=<?=$uin?>">Sprache</a>&nbsp;</font><br><br></td>
				<td><font size=2><a href="<?=$PHP_SELF?>?sortby=<? echo ($sortby=="anz desc") ? "anz asc" : "anz desc"; ?>&uin=<?=$uin?>">Anz</a>&nbsp;</font><br><br></td>
<? if($loggedin){ ?>
				<td><font size=2>Delete&nbsp;</font><br><br></td>
				<td><font size=2>Edit</font><br><br></td>
				<td><font size=2>In&nbsp;Store</font><br><br></td>
<? }; ?>
			</tr>
<?
$abfrage = sql("select id,titel,anz,lang,instore from $tbl_list ORDER by $sortby,titel");
while (list($id,$theaser,$anz,$lang,$instore) = mysql_fetch_row($abfrage)){
	$theaserprint = $theaser;
	//if (strlen($theaser) > 30)  $theaserprint = substr($theaserprint,0,25)."..."; ?>
	 		<tr>
				<td width="300"><font size=2><?=$theaserprint?></font></td>
				<td width="50" align="center"><font size=2><?=$lang?></font></td>
				<td width="30" align="center"><font size=2><?=$anz?></font></td>
<?	if($loggedin){?>
//////////////////////////////////////
//Note part here to
				<td width="30" align="center"><font size=2><a href="del.php?id=<?=$id?>&uin=<?=$uin?>" style="text-decoration: none;">[del]</a></font></td>
				<td width="39" align="center"><font size=2><a href="editp.php?id=<?=$id?>&uin=<?=$uin?>" style="text-decoration: none;">[edit]</a></font></td>
//here
//////////////////////////////////////

				<td width="39" align="center"><font size=2><a href="<?=$PHP_SELF?>?uin=<?=$uin?>&sortby=<?=$sortby?>&action=changestore&id=<?=$id?>" style="text-decoration: none;"><? echo ($instore) ? "yes" : "no";?></a></font></td>
<?	};?>
			</tr>
<?};?>
		</table>
Total Films: <?=mysql_result(mysql_query("SELECT count(*) FROM $tbl_list"),0);?>
		</font>
	</body>
</html> 
//////////////////////////////////////
// End of code example
//////////////////////////////////////
Take a look at the special marked part in the code. If this part isnt included, the i still have errors, but only about 20% than with the code (lol).
The code should be 100% correct also, and on *nix servers it runs very well.

Theremore the output is always different. It outputs what it wants :) with part like "dddfffff" and 200x a "F", this also in a loop where thats nearly impossible :)

Also i tested it with some friends. At the time it runned well on my localhost (with a smaller code), i wget the document from an other server (ping ~20) and had some more errors in it, but constant more (tried it more than once).
An other person tried it also (ping ~60) and never reached the dokument how it should be.

Hope i can help out with this :p

Greets

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-26 07:30 UTC] mail at seen dot ch
OK, its like i expected.
When you fill out a loop (any kind of one) with enough data it happens (a overflow??)

<?
//create an array with 100 items with different informations
for($i=0;$i<100;$i++){
srand((double)microtime()*1000000);
$testarray[] = md5(uniqid(rand()));
}
?>
	<table>
<?
//output from this array, 3 times for enougth data
for($i=0;$i<100;$i++){
?>		<tr>
			<td>
				<font face="Tahoma, Tahoma, Tahoma" size="1" color="black" style="text-decoration:none">
				<a href="#" target="top"><?=$testarray[$i]?></a></font>
			</td>
			<td>
				<font face="Tahoma, Tahoma, Tahoma" size="1" color="black" style="text-decoration:none">
				<a href="#" target="top"><?=$testarray[$i]?></a></font>
			</td>
			<td>
				<font face="Tahoma, Tahoma, Tahoma" size="1" color="black" style="text-decoration:none">
				<a href="#" target="top"><?=$testarray[$i]?></a></font>
			</td>
		</tr>
<? };?>
	</table>
 [2002-02-08 04:03 UTC] dave at rowlands dot info dot
run apache in single process mode eg:

apache -X

It's probably a bug in the duplicatesocket
 [2002-03-07 04:45 UTC] hholzgra@php.net
stop! the -X option is for debugging purposes only,
as all requests will now be serialized and handled
by a single apache process

this is *not* what you want in a production environment!
the -X option is meant for debugging purposes only, as
debugging a apache process farm can become a nightmare ...

if the problem does *not* show up with -X then it is
most likely related to process coordination or something,
which makes it harder to debug ... :(

but once again: -X is *not* a solution, it is just one
of the means to find the cause 


 [2002-03-20 14:25 UTC] greg dot burri at net2000 dot ch
I have find a ""solution"" :
I have activates gzip compression (see php.ini) and it works.....
 [2002-03-21 04:56 UTC] hholzgra@php.net
no, you have found a workaround that hides the actual problem for now, maybe due to reduced output buffer sizes ...
 [2002-03-21 07:07 UTC] wez@php.net
Sounds like it is related to Bugs #15613 and #15245.
This really needs sorting out for PHP 4.2
 [2002-06-18 19:01 UTC] sniper@php.net
Try Apache 1.3.24 and PHP 4.2.1.
Reopen if problem persists.

 [2002-07-24 02:43 UTC] sinachen at chtd dot com dot tw
i try Apache 1.3.26 and PHP 4.2.1
it's work fine :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 07:01:30 2024 UTC