php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52411 segfault: curl_multi_* + 2 or more FTP urls
Submitted: 2010-07-23 08:16 UTC Modified: 2010-07-27 04:57 UTC
From: profy dot net at gmail dot com Assigned:
Status: Duplicate Package: cURL related
PHP Version: 5.3.3 OS: win xp, ubuntu 9.10, others
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 - 11 = ?
Subscribe to this entry?

 
 [2010-07-23 08:16 UTC] profy dot net at gmail dot com
Description:
------------
segfault when requesting 2 or more FTP urls with curl_multi_*

Appears both under WIN XP SP3, ubuntu 8.10, 9.10

segfault when calling test script from command line, for example: 
d:/www4/php5/php -q -c d:/www4/php.ini -f curl_ftp_bug_test.php
and also as apache2 module:
http://localhost/curl_ftp_bug_test.php

php.ini used is default from distribution (php.ini-production) wit only curl extension enabled:
extension=php_curl.dll

Reproduced every time when call test script.

This bug first reported here:
http://bugs.php.net/bug.php?id=52284
But was set to "Bogus" by mistake.

Test script:
---------------
<?php
function multi_request($urls, $url_options = array()) {
	$mh = curl_multi_init();
	foreach ($urls as $id => $url) {
		$curly[$id] = curl_init();
		curl_setopt($curly[$id], CURLOPT_URL, $url);
		curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, true);
		// I've add this opt to speed up request, bug appearing with or without this line
		curl_setopt($curly[$id], CURLOPT_NOBODY, true);
		curl_multi_add_handle($mh, $curly[$id]);
	}

	$running = null;
	do {
		$status = curl_multi_exec($mh, $running);
		usleep(1000);
	} while($status == CURLM_CALL_MULTI_PERFORM || $running);

	foreach ($curly as $id => $c) {
		$result[$id] = curl_multi_getcontent($c);
		curl_multi_remove_handle($mh, $c);
		curl_close($c);
	}
	curl_multi_close($mh);

	return $result;
}

$urls = array(
	"4358521"	=> "ftp://ftp.ea.com/pub/ea/patches/nfs-underground/pc/en-uk/NFSU_EUROPE_PATCH_4.exe",
	"7458288"	=> "ftp://ftp.nero.com/software/plugins/WMAPlugin20937.exe",
);

echo "<pre>";
print_R(multi_request($urls));
echo "</pre>";


Expected result:
----------------
No segfault :)

Actual result:
--------------
segmentation fault

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-27 01:06 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2010-07-27 01:06 UTC] kalle@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.


 [2010-07-27 04:57 UTC] srinatar@php.net
-Status: Feedback +Status: Duplicate
 [2010-07-27 04:57 UTC] srinatar@php.net
closing this bug as duplicate of bug #52284
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 06:01:27 2019 UTC