Bug #74334 [NEW]: multicurl infinite loop

From: Date: Wed, 29 Mar 2017 15:02:32 +0000
Subject: Bug #74334 [NEW]: multicurl infinite loop
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208148@lists.php.net to get a copy of this message
From: julien at palard dot fr Operating system: Debian GNU/Linux 8.7 (jessie) PHP version: Irrelevant Package: cURL related Bug Type: Bug Bug description:multicurl infinite loop Description: ------------ Copying and pasting the example on http://php.net/manual/en/function.curl-multi-init.php give an infinite loop on: while ($active && $mrc == CURLM_OK) { if (curl_multi_select($mh) != -1) { because curl_multi_select always returns -1. I tried stracing but found nothing relevant, there's no syscall during the infinite loop, just before the loop I'm getting: [pid 11348] 1490799411.296356 close(8) = 0 [pid 11348] 1490799411.296397 madvise(0x7f425f426000, 8368128, MADV_DONTNEED) = 0 [pid 11348] 1490799411.296428 exit(0) = ? [pid 11348] 1490799411.296473 +++ exited with 0 +++ [pid 11347] 1490799411.359286 <... poll resumed> ) = 1 ([{fd=9, revents=POLLIN}]) [pid 11347] 1490799411.359362 ioctl(9, FIONREAD, [501]) = 0 [pid 11347] 1490799411.359438 recvfrom(9, "\22>\201\200\0\1\0\2\0\r\0\f\3lxr\3php\3net\0\0\1\0\1\300\f\0"..., 2048, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("167.[redacted].1")}, [28->16]) = 501 [pid 11347] 1490799411.359594 poll([{fd=9, events=POLLIN}], 1, 4915) = 1 ([{fd=9, revents=POLLIN}]) [pid 11347] 1490799411.469988 ioctl(9, FIONREAD, [105]) = 0 [pid 11347] 1490799411.470060 recvfrom(9, "|b\201\200\0\1\0\1\0\1\0\0\3lxr\3php\3net\0\0\34\0\1\300\f\0"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("167.[redacted].1")}, [28->16]) = 105 [pid 11347] 1490799411.470150 close(9) = 0 [pid 11347] 1490799411.470231 madvise(0x7f425fc27000, 8368128, MADV_DONTNEED) = 0 [pid 11347] 1490799411.470284 exit(0) = ? [pid 11347] 1490799411.470346 +++ exited with 0 +++ The presence of [pid …] means that they are forks, not the main process, which is looping. Tested on 7.0.16-3 and 5.6.30-0+deb8u1 (from Debian packages). Test script: --------------- The example on http://php.net/manual/en/function.curl-multi-init.php which is: <?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: ---------------- An error or a result. Actual result: -------------- An infinite loop. -- Edit bug report at https://bugs.php.net/bug.php?id=74334&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74334&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74334&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74334&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74334&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74334&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74334&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74334&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74334&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74334&r=support Expected behavior: https://bugs.php.net/fix.php?id=74334&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74334&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74334&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74334&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74334&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74334&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74334&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74334&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74334&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74334&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74334&r=mysqlcfg

« previous php.bugs (#208148) next »