|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3187 CPU overload with fopen() and fgets()
Submitted: 2000-01-12 06:15 UTC Modified: 2002-10-01 14:14 UTC
Avg. Score:2.7 ± 1.2
Reproduced:0 of 0 (0.0%)
From: alister at xcel dot net dot au Assigned:
Status: Wont fix Package: Misbehaving function
PHP Version: 3.0.14 OS: NT 4.0 SP 5 on intel
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2000-01-12 06:15 UTC] alister at xcel dot net dot au
I'm using latest release PHP4 beta 3 (couldn't pick that as a selection in the PHP Version pull-down - sorry). Also latest win32 Apache.

When I run the code below on an external URL (in this case PHP gets as far as entering the while loop but appears to go out of control on the fgets(). I am getting variable CPU usage between 95 and 100%... it's maxing out my processor! I don't know how long it would go for... I eventually rebooted (manuy times!) because I couldn't kill the PHP.exe process. 

NOTE: The script max timeout variable doesn't work outside UNIX and this is something to overcome, please!

I tried a work around using readfile() and explode() to get the array back, but readfile() sends to standard output and I don't know how to suppress this.

I'm notifying of this bug (I'm not alone... there's a note on one of the online manual pages about the exact same error in PHP v3.something) but also asking for any workarounds for the time being.




function grabFile ($url, $ignoreme)
  $fp = fopen ($url, "r");
  $i = 0;
  echo " ";
  flush ();
  while (!feof($fp))
    $file[$i] .= fgets ($fp,1024);
    //echo $i." <br>";
    flush ();
  echo " ";
  flush ();
  return $file;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-01 14:14 UTC]
We are sorry, but can not support PHP 3 related problems anymore.
Momentum is gathering for PHP 5, and we think supporting PHP 3 will
lead to a waste of resources which we want to put into getting PHP 5
ready. Ofcourse PHP 4 will will continue to be supported for the
forseeable future.

using curl in php4 might help
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jun 12 17:01:23 2021 UTC