php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70425 Multicurl runs forever with PHP >= 5.6
Submitted: 2015-09-04 09:15 UTC Modified: 2018-08-03 15:04 UTC
Votes:9
Avg. Score:4.4 ± 0.8
Reproduced:9 of 9 (100.0%)
Same Version:6 (66.7%)
Same OS:3 (33.3%)
From: cyberline@php.net Assigned: cmb (profile)
Status: Duplicate Package: cURL related
PHP Version: 5.6.12 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cyberline@php.net
New email:
PHP Version: OS:

 

 [2015-09-04 09:15 UTC] cyberline@php.net
Description:
------------
If you use multicurl simmilar to the sample mentioned here:

http://php.net/manual/en/function.curl-multi-init.php

your code will run forever or reach max_execution_time.

Test script:
---------------
<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();

// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://lxr.php.net/");
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
//execute the handles
do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}

//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);


Expected result:
----------------
HTML of both URL's

Actual result:
--------------
Nothing happens.

strace output shows endless:

select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})
select(5, [], [4], [], {1, 0})          = 1 (out [4], left {0, 999999})

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-16 18:14 UTC] apringle at gmail dot com
I ran into this when testing a PHP 5.6.13 system. However, I then noticed the same behavior happening on a system running PHP 5.5.27. This particular system had a newer version of libcurl installed. Downgrading to the libcurl (7.19) provided by my CentOS distro fixed the behavior.

Using the test case provided in the bug report, here are the results from some different platforms I was able to test on:

Centos6.6, PHP 5.5.27, libcurl-7.19.7-46: HTML response shown in output
Centos6.6, PHP 5.5.27, libcurl-7.29: Hangs until execution timeout
Debian8, PHP 5.5.29, libcurl-7.38.0-4: Hangs until execution timeout
Debian8, PHP 5.6.13, libcurl-7.38.0-4: Hangs until execution timeout
OSX 10.10.5, PHP 5.5.7, libcurl 7.43.0: Hangs until execution timeout
 [2015-11-12 16:02 UTC] carlos dot buenosvinos at gmail dot com
It an issue already discussed, please see https://bugs.php.net/bug.php?id=63411
 [2018-08-03 15:04 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2018-08-03 15:04 UTC] cmb@php.net
Basically a duplicate of bug #63411.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Mar 25 09:01:26 2019 UTC