PHP 4.0 Bug #6021 Updated: Script is getting killed although it doesn't consume very much memory
| From: | sniper@php.net | Date: | Thu, 07 Dec 2000 16:27:16 +0000 |
| Subject: | PHP 4.0 Bug #6021 Updated: Script is getting killed although it doesn't consume very much memory | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-40406@lists.php.net to get a copy of this message | ||
ID: 6021
Updated by: sniper
Reported By: juhl@eisenstein.dk
Status: Closed
Bug Type: Scripting Engine problem
Assigned To:
Comments:
Reopen, if this still happens when using latest snapshot
from http://snaps.php.net/
--Jani
Previous Comments:
---------------------------------------------------------------------------
[2000-11-01 11:13:10] sniper@php.net
Please try a newer snapshot. This might be fixed now.
--Jani
---------------------------------------------------------------------------
[2000-08-14 03:37:26] juhl@php.net
I'm currently using php4-200008130745 and compiled it without memory limit (that is, without
the --enable-memory-limit configure parameter), and now everything seems to be working nicely, and I
have no problems with scripts or apache processes consuming a lot of memory, but if I enable the
memory-limit, then the scripts start dying again... Could there be a bug regarding
--enable-memory-limit?
Regards,
Jesper Juhl
juhl@eisenstein.dk
---------------------------------------------------------------------------
[2000-08-08 10:28:04] juhl@php.net
The following script exhibits the described behaviour (the amount of time until the problem shows
itself can vary depending (I guess) on server load).
The function makeStrSafe() is defined in juhlFunctions.php and looks like this:
function makeStrSafe($str) {
$str = trim($str);
$str = eregi_replace("[^-a-zA-ZæøåÆØÅ 0-9.,_]", "", $str);
return $str;
}
The session.php file is rather large, and so is the db.php file that defines the db class (included
in session.php), so I'll only post them on request.
The err_return() function currently does nothing, it's just defined like this:
function err_return($a, $b) {
exit();
}
<?php
$INCLUDE_DIR = "/include/";
require($DOCUMENT_ROOT.$INCLUDE_DIR."juhlFunctions.php");
$username = makeStrSafe($username);
$password = makeStrSafe($password);
require($DOCUMENT_ROOT.$INCLUDE_DIR."session.php");
$k = makeStrSafe($k);
if ($k != $klub) {
$klub = $k;
}
session_register("klub");
if (empty($klub)) {
header("Location: http://".$SERVER_NAME."klubVaelger.php");
exit();
}
$dbase = new db;
if (!$dbase->connect()) {
err_return($dbase->errno, $dbase->errmsg);
}
$filename = "medlem_forside.php";
if (!($fp = fopen($filename, "r"))) {
err_return("r", "Kunne ikke åbne filen $filename");
}
if (!($contents = fread($fp, filesize($filename)))) {
err_return("r", "Kunne ikke læse filen $filename");
}
fclose($fp);
$dbase->query = "LOCK TABLES klub READ, person READ";
if (!$dbase->execQuery()) {
err_return($dbase->errno, $dbase->errmsg);
}
$dbase->query = "SELECT navn FROM klub WHERE post_id='$klub'";
if (!$dbase->execQuery()) {
err_return($dbase->errno, $dbase->errmsg);
}
if (mysql_num_rows($dbase->result) == 0) {
echo "Klubben findes ikke<br>";
exit();
}
$row = mysql_fetch_array($dbase->result);
$contents = eregi_replace("<klubNavn>", "$row[navn]", $contents);
$dbase->query = "SELECT fornavn, efternavn FROM person WHERE
post_id='$row[leder_id]'";
if (!$dbase->execQuery()) {
err_return($dbase->errno, $dbase->errmsg);
}
$row = mysql_fetch_array($dbase->result);
$contents = eregi_replace("<klubLederNavn>", $row[fornavn]."
".$row[efternavn], $contents);
$dbase->query = "UNLOCK TABLES";
if (!$dbase->execQuery()) {
err_return($dbase->errno, $dbase->errmsg);
}
echo $contents;
?>
---------------------------------------------------------------------------
[2000-08-08 09:57:46] stas@php.net
Please provide reproducing script for this behaviour.
---------------------------------------------------------------------------
[2000-08-08 09:26:52] juhl@eisenstein.dk
After upgrading to latest CVS I'm getting errors due to the memory limit that I've not
encountered before.
Even small scripts (that worked perfectly with PHP 4.0.0) are now getting killed when theyt hit my
mem-limit of 25MB.
I think something is leaking memory since I do not get this error for about the first hour after
restarting Apache, but after aproximately 1 hour the scripts start to crash with this message:
Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 256 bytes) in
Unknown on line 0
Running "top" or "ps" shows no processes using huge amounts of mem, and each
httpd process is consuming about 3% of my 128MB RAM each time they run.
Restarting apache makes the problem go away again for about half an hour to an hour.
I'm running Slackware Linux 7.0, Apache 1.3.12, PHP 4.02-dev (php4-200008080345). PHP was
configured like this:
./configure --with-mysql=/usr/local/mysql --with-apxs=/usr/local/apache/bin/apxs
--with-config-file-path=/etc/httpd --enable-calendar --enable-trans-sid --enable-versioning
--enable-track-vars --with-gd --with-jpeg-dir --with-tiff-dir --with-png-dir --with-ttf
--with-zlib-dir --enable-memory-limit=yes --with-openssl --disable-debug
Best regards,
Jesper Juhl
---------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view the rest of the comments,
please view the bug report online.
Full Bug description available at: http://bugs.php.net/?id=6021