php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40138 curl_multi, PHP/CLI crash, abnormally CPU load and Blue screen
Submitted: 2007-01-15 20:13 UTC Modified: 2007-01-16 08:29 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rvadmin at mail dot ru Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.2.0 OS: Windows XP
Private report: No CVE-ID: None
 [2007-01-15 20:13 UTC] rvadmin at mail dot ru
Description:
------------
I use curl_multi on php command line version at Windows XP.
After some time, php crashes (sometimes php.net, sometimes php_curl.dll). If php after 1 hour working normal, after 2 hours winsock crashes. My script is  web crawler that downloading web pages and save them.
 I tried many builds of Windows XP, many versions of PHP5 and many computers!!!.
On php 5.2.0 php not crashes, but windows crashes!!! (blue screen of death:).
Usually I use 30 threads.

I need help, because I dont know how to resolve this problem! 
Please, sorry for my bad English!!!

Thank you.



Reproduce code:
---------------
<?
/*Only part of script*/
$urls=array("http://php.net"/*.... and other*/);
function read_header($ch, $string)
{
	$length = strlen($string);
	if(substr($string,0,13)=="Content-Type:" && !preg_match("#(text/html|text/plain)#",$string))
        return false; # if it is not HTML
	else
	return $length;
}
$mh = curl_multi_init();

foreach ($urls as $i => $url)
{

	$conn[$i]=curl_init();
	curl_setopt($conn[$i],CURLOPT_URL,$url);
	curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string
	curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,30);//timeout
	curl_setopt($conn[$i], CURLOPT_TIMEOUT, 120);
	curl_setopt($conn[$i], CURLOPT_MAXREDIRS, 1);
	curl_setopt($conn[$i], CURLOPT_NOSIGNAL, 1);
       	curl_setopt($conn[$i], CURLOPT_NOPROGRESS, 1);
       	curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1);
	curl_setopt($conn[$i],CURLOPT_SSL_VERIFYPEER,0);
	curl_setopt($conn[$i],CURLOPT_SSL_VERIFYHOST,0);
	curl_setopt($conn[$i],CURLOPT_HEADERFUNCTION, 'read_header');
	curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);
	curl_setopt($conn[$i],CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");

	curl_multi_add_handle ($mh,$conn[$i]);

}

do { $mrc=curl_multi_exec($mh,$active); } while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active and $mrc == CURLM_OK) {
  // wait for network
  if (curl_multi_select($mh) != -1) {
   // pull in any new data, or at least handle timeouts
   do {
     $mrc = curl_multi_exec($mh, $active);
   } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  }
}
$ret=array();

foreach ($data as $i => $url)
{
         if (($err = curl_error($conn[$i])) == '')
         {
                 $c=curl_multi_getcontent($conn[$i]);
                 if($c!==false)
                 $ret[$i]=$c;
         }

	curl_multi_remove_handle($mh,$conn[$i]);
	curl_close($conn[$i]);
}
curl_multi_close($mh); 
/*...*/
?>

Expected result:
----------------
Curl and php/cli must work normal without high CPU loading when working long time and without winsock and php crashes.

Actual result:
--------------
Php crashes or (if php works long time) winsock crashes or windows XP (at PHP 5.2.0 ) blue screen crash

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-15 20:14 UTC] rvadmin at mail dot ru
OOPS, not php.net but php.exe!
(sometimes php.exe, sometimes
php_curl.dll)
 [2007-01-15 20:37 UTC] tony2001@php.net
Windows crashes are not PHP problems, even if they are reproducible only with PHP.
 [2007-01-16 08:18 UTC] rvadmin at mail dot ru
ok, but why php_curl.dll crashes on PHP <5.2.0???
 [2007-01-16 08:29 UTC] tony2001@php.net
Update PHP to the latest version.
I don't think we can go to the past and re-fix something that has been already fixed in 5.2.0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 21:01:29 2024 UTC