php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47773 cURL multi crashes
Submitted: 2009-03-25 14:08 UTC Modified: 2009-05-05 00:53 UTC
From: entpman at gmail dot com Assigned: pajoye (profile)
Status: Not a bug Package: cURL related
PHP Version: 5.2.9 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: entpman at gmail dot com
New email:
PHP Version: OS:

 

 [2009-03-25 14:08 UTC] 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() 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-06 20:45 UTC] 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-05-05 00:53 UTC] jani@php.net
Bugs in libcurl are not bugs in PHP. :) (see above comment and link)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 07:01:27 2024 UTC