ID:               44954
 User updated by:  abakker at gmx dot net
 Reported By:      abakker at gmx dot net
-Status:           Feedback
+Status:           Open
 Bug Type:         Reproducible crash
 Operating System: Win XP
 PHP Version:      5.2.6
 New Comment:

I added a sleep(1) and set max_execution_time to 999. After 172
iterations the Apache server hangs (does not respond to page requests
anymore). The script continues very slowly at this point, it times out
on every file_get_contents request (in the error log you see the error
message mentioned at the top of this bug report for every iteration).

The total number of threads in Windows Task Manager does not increase
when running the script. My system is also not running out of resources,
I have 3 Gb memory of which 2.6 Gb is available.

When you replace file_get_contents with http_get or curl_exec the
problem does not occur. Seems to me that this indicates that there is
something wrong with file_get_contents.

In any case a PHP script should not cause the Apache server to
hang/crash (Apache does not respond to page requests for any user
anymore) and bring a production system down.


Previous Comments:
------------------------------------------------------------------------

[2008-05-18 00:20:28] [EMAIL PROTECTED]

I really doubt this is any bug in PHP anyway. You propably just run out
of Apache threads/childs with that script that doesn't really give
Apache any chance. Try adding some 'sleep(1);' line inside the for()
loop.

------------------------------------------------------------------------

[2008-05-11 11:15:41] abakker at gmx dot net

In the Apache error log it just says the connected party failed to
respond (the complete message is in the beginning of this bug report).

I tried the backtrace tools, but did not manage to get a backtrace. I
looked at the processes. I have two httpd.exe processes when I start
Apache. When I reproduce the problem, the two processes remain. I guess
technically this means the Apache server does not crash, but hangs and
this is the reason why I do not get a backtrace?

Anyway, the two httpd.exe processes keep on running, but any web page
request fails (internet explorer displays the standard page that it
could not access the requested web page). Apache no longer seems to
respond to requests. The two httpd.exe processes use no cpu when the
problem occurs.

A restart of Apache does not give any error message, but does not solve
the issue. A stop and start is needed. Not sure whether this tells you
something.

Anyway, were you able to reproduce the problem yourself? That would be
helpful, if so, you could do any backtracing or other diagnosis
yourself. I am not familiar with the diagnostic tools, it would be much
better if you could do it.

------------------------------------------------------------------------

[2008-05-10 23:02:22] [EMAIL PROTECTED]

Nevermind the Apache log question..of course you checked that. :) But
there's no indication that anything crashed anywhere..

------------------------------------------------------------------------

[2008-05-10 23:01:09] [EMAIL PROTECTED]

Are you sure it's a crash? If so, it's might be PHP that is crashs so
where's the backtrace? And did you check the Apache logs for any
possible information about this issue..?

Instructions how to get a backtrace under Windows:
http://bugs.php.net/bugs-generating-backtrace-win32.php 


------------------------------------------------------------------------

[2008-05-09 11:22:01] abakker at gmx dot net

Description:
------------
Apache crashes if a lot of file_get_contents are done. The Apache
error.log only contains this (I guess this just confirms that the Apache
server has crashed and no longer responds): [Fri May 09 12:15:04 2008]
[error] [client 192.168.0.1] PHP Warning: 
file_get_contents(http://localhost/test.htm) [<a
href='function.file-get-contents'>function.file-get-contents</a>]:
failed to open stream: A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond.\r\n in
C:\\Andre\\Apache\\test.php on line 6


Reproduce code:
---------------
The following PHP script reproduces the problem:

<?php
echo '<pre>';
for ($i=1;;$i++)
{ echo $i."\n";
  flush();ob_flush();
  $contents = file_get_contents('http://localhost/test.htm');
}
?>

After 203 iterations the Apache server crashes. The result is the same
whether localhost or IP address is used.

The problem depends on the contents of the test.htm file. If it only
contains

<html>
<body>
</body>
</html>

the script runs until it reaches the max execution time.

The test.htm that reproduces the problem contains:

<html>
<head>
<link rel="stylesheet" href="/systeem/style/style.css">
<title>V.V. De Meern</title>
<meta name="description" content="V.V. De Meern">
<meta name="robots" content="index,follow">
<script src="/beheer/include/header.js"></script>
</head>
<body>
<script src="menu.js"></script>
<a href="menu.html"></a>
<h1>Home pagina A1</h1>
<p><img src="a1.jpg" border="0" alt="" /></p>
<h1>Spelers</h1>
<p>Nicky Vermeulen, Jon Gruters, Jerryl Smeenk, Bram van Wiggen, Rolf
van
Elderen, Sander van der Woude, Melvin van Nood, Jorgos Katsivilis, Leo
Wakelkamp, Chen Margolin, Luis Plein, Danny Berkhouwer, Whaheed
Khodabaks,
Alessandro Damen, Thomas van Amerongen</p>
<h1>Leiders</h1>
<p>John Dunsbergen, Joost Satink, Lex van der Woude</p>
<script src="/beheer/include/footer.js"></script>
</body>
</html>

Expected result:
----------------
Run until max execution time exceeded.

Actual result:
--------------
Crashed beforehand.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44954&edit=1

Reply via email to