php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26332 Using curl_multi_exec with curl_multi_fdset doesnt work
Submitted: 2003-11-20 09:48 UTC Modified: 2005-01-26 04:47 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: foxkill at gmx dot de Assigned:
Status: Closed Package: cURL related
PHP Version: 5CVS-2004-03-15 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: foxkill at gmx dot de
New email:
PHP Version: OS:

 

 [2003-11-20 09:48 UTC] foxkill at gmx dot de
Description:
------------
I try to use curl_multi_fdset() together with curl_multi_exec() in php5. But this doesn't work.
I modelled my php code after the sample (multi-app.c) which is provided by the curl-src package.

Reproduce code:
---------------
this is the code I use for php5 (three single curl handles were added):

while (CURLM_CALL_MULTI_PERFORM == curl_multi_exec($m, $still_running)) 
  ;

while ($still_running) {
     $fd = curl_multi_select($m, 1);

     switch($fd) {
     	case -1:
        break;

        case 0:
        default:
        while (CURLM_CALL_MULTI_PERFORM == curl_multi_exec($m, $still_running))
          ;
    }
}

Expected result:
----------------
The code should behave like the multi-app.c sample. See [curl-src]/docs/examples/multi-app.c.

Actual result:
--------------
The code runs in an endless loop. Because curl_multi_exec() (alias curl_multi_perform()) needs to reference the variables readfds, writefds which were set by a previous call to curl_multi_fdset(). But these fdsets have gone out of scope. The C Code works because the fdsets are still present on the stack. See man 3 curl_multi_fdset for further details. curl --version gives:

curl 7.10.8 (i686-pc-linux-gnu) libcurl/7.10.8 OpenSSL/0.9.7c zlib/1.1.4
Protocols: ftp gopher ldap http file https ftps
Features: SSL libz NTLM


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-25 05:08 UTC] foxkill at gmx dot de
You'll find the script to reproduce the error under:
http://www.secnow.de/websearch/websearch.txt

The script runs either in an endless loop or if it terminates it prints:
Last leak repeated 2 times
/opt/local/src/lamp/php5-src/ext/curl/multi.c(62) :  Freeing 0x40291A34 (8 bytes), script=websearch.php
=== Total 4 memory leaks detected ===
 [2004-03-15 10:48 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Works fine for me with latest CVS snapshot.

 [2004-03-17 06:07 UTC] foxkill at gmx dot de
I did try the latest snapshots. But the problem is still existent. Perhaps I should have mentioned that I use a debug version of php-cli and the php curl library as shared module. In a realease build with compiled in curl it seems to work as expected. Did you read my additional comments that I provided with the example script on http://www.secnow.de/websearch/websearch.txt? The problem seems to be related to the fd_set variables that are set in curl_multi_perform. When curl_multi_exec is called these fd_set variables are no longer available.
 [2005-01-10 19:40 UTC] dtorop933 at gmail dot com
This appears related to the version of libcurl installed.  Running libcurl 7.12.3, foxkill's code works properly for me.  Trying curl 7.12.0, 7.12.1, and 7.12.2, I see the same endless loop as foxkill.  (This with PHP 5.0.3 on Linux machines running either Debian sarge w/2.6.10 kernel or redhat 9 w/2.4.27 kernel.)

The key revision to libcurl seems to be a change to how curl handles file descriptors on 2004/11/19 08:52:33 UTC.  Using curl source from CVS before this date I get the endless loop, after this things work.  I don't understand ramifications of the patch, though, clearly isn't all or nothing, as sniper saw no problem on 3/15/04, well before the patch or libcurl 7.12.3.
 [2005-01-26 04:47 UTC] sniper@php.net
If you can reproduce this with latest Curl release and the latest PHP 5 snapshot, reopen.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 05:01:29 2024 UTC