#47773 [Ver]: cURL multi crashes

From: Date: Sun, 03 May 2009 21:57:23 +0000
Subject: #47773 [Ver]: cURL multi crashes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-136695@lists.php.net to get a copy of this message
 ID:               47773
 Updated by:       pajoye@php.net
 Reported By:      entpman at gmail dot com
 Status:           Verified
 Bug Type:         cURL related
-Operating System: win32 only - WIN XP SP2
+Operating System: *
 PHP Version:      5.2.9
 Assigned To:      pajoye
 New Comment:

not only windows


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

[2009-04-06 20:45:05] daniel at haxx dot se

I'm convinced this is a bug in libcurl, see this analysis by 
Sergii Volchkov:

http://curl.haxx.se/mail/lib-2009-04/0028.html

(AFAIK, there is nobody working on a fix for this.)

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

[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



Thread (11 messages)

« previous php.bugs (#136695) next »