#47773 [Opn->Asn]: cURL multi crashes

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               47773
 Updated by:       [email protected]
 Reported By:      entpman at gmail dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         cURL related
-Operating System: WIN XP SP2
+Operating System: win32 only - WIN XP SP2
 PHP Version:      5.2.9
 Assigned To:      pajoye


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

[2009-03-25 15:29:52] entpman at gmail dot com

I tried version 5.3.0RC2-dev same results.

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

[2009-03-25 14:08:06] entpman at gmail dot com

Description:
------------
The program will work fine for hundreds of downloads then suddenly
crashes.

Reproduce code:
---------------
<?php
$data = downloadurls(
			array(
				array(
					'url' => 'http://www.google.com'
				),
				array(
					'url' => 'http://www.yahoo.com'
				)
			)
		);

// of course more urls are needs

function downloadurls($downloads,$cookie = null){	
	$timeout = 30;	
	$mcurl = curl_multi_init();
	$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12)
Gecko/2009201 Firefox/3.0.0.1";
	
	foreach($downloads as $key=>$download){	    
		$url = $download['url'];
		$ch = curl_init();       
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
		curl_setopt($ch, CURLOPT_USERAGENT, $agent);
		if(!empty($download['postdata'])){
			curl_setopt($ch, CURLOPT_POST, 1); 
		    curl_setopt($ch, CURLOPT_POSTFIELDS,$download['postdata']); 
		}   		
		if(!empty($cookie)){
			@unlink($cookie);
			//echo "added cookie\n";
			curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
			curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
		}
		if(!empty($download['proxy'])){
			curl_setopt($ch, CURLOPT_PROXY, $download['proxy']);
		}
		curl_multi_add_handle($mcurl, $ch);
		$downloads[$key]['handle'] = $ch;        	    
	}    

    do {
	    $n=curl_multi_exec($mcurl,$active);
	    usleep(100);
	}	
	while ($active);
			
    foreach($downloads as $key=>$download){    	
        $ch = $download['handle'];        
        $done_content = curl_multi_getcontent($ch);
        if(curl_errno($ch) == 0) {
			$downloads[$key]['picture'] = $done_content;
        } else {
            exit('error');	            
        }
        curl_multi_remove_handle($mcurl, $ch);
        curl_close($ch);       
    }
	
	curl_multi_close($mcurl);
	return $downloads;
}
?>

Actual result:
--------------
backtrace:

	php_curl.dll!_Curl_llist_insert_next()  + 0x48 bytes	
 	php_curl.dll!_Curl_hash_add()  + 0x74 bytes	
 	php_curl.dll!_Curl_cache_addr()  + 0x6d bytes	
 	php_curl.dll!_Curl_addrinfo4_callback()  + 0x82 bytes	
 	php_curl.dll!_Curl_addrinfo4_callback()  + 0x14 bytes	
 	php_curl.dll!_Curl_getaddrinfo()  + 0x317 bytes	
 	msvcrt.dll!77c3a3b0() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for
msvcrt.dll]	
 	kernel32.dll!7c80b683() 


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


-- 
Edit this bug report at http://bugs.php.net/?id=47773&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.