From: rvadmin at mail dot ru
Operating system: Windows XP
PHP version: 5.2.0
PHP Bug Type: cURL related
Bug description: curl_multi, PHP/CLI crash, abnormally CPU load and Blue screen
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
--
Edit bug report at http://bugs.php.net/?id=40138&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=40138&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=40138&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=40138&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40138&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=40138&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40138&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40138&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40138&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40138&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40138&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=40138&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=40138&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40138&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40138&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40138&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40138&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40138&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40138&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40138&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40138&r=mysqlcfg