0) { $fd = curl_multi_select($m, 1); switch($fd) { case -1: break; case 0: default: while (CURLM_CALL_MULTI_PERFORM == curl_multi_exec($m, $running)); } } curl_multi_close ($m); ?> -------------------------------------------------------------------- To help diagnose the problem I set a breakpoint on zif_curl_multi_select(): Breakpoint 2, zif_curl_multi_select (ht=2, return_value=0x402920a4, this_ptr=0x0, return_value_used=1) at /opt/local/src/lamp/php5-src/ext/curl/multi.c:135 135 double timeout = 1.0; (gdb) list 130 php_curlm *mh; 131 fd_set readfds; 132 fd_set writefds; 133 fd_set exceptfds; 134 int maxfd; 135 double timeout = 1.0; 136 struct timeval to; 137 138 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|d", &z_mh, &timeout) == FAILURE) { 139 return; (gdb) Let's take the address of readfds to explain the problem: (gdb) p &readfds $52 = (fd_set *) 0xbfffc720 0xbfffc720 is a variable declared on the stack, which goes out of scope if the function zif_curl_multi_select returns. Looking at the value of readfds after FD_ZERO(&readfds) and select(maxfd + 1, &readfds, &writefds, &exceptfds, &to) have been called: (gdb) p readfds $58 = {__fds_bits = {2176, 0 }} Now I set a breakpoint in curl_multi_perform to handle the following call to zif_curl_multi_exec(). (gdb) bt #0 curl_multi_perform (multi_handle=0x82db968, running_handles=0xbfffc7b4) at multi.c:460 #1 0x402e1ded in zif_curl_multi_exec (ht=2, return_value=0x4029ac94, this_ptr=0x0, return_value_used=1) at /opt/local/src/lamp/php5-src/ext/curl/multi.c:173 #2 0x081f7de7 in zend_do_fcall_common_helper (execute_data=0xbfffd370, opline=0x40298970, op_array=0x82dfa48) at /opt/local/src/lamp/php5-src/Zend/zend_execute.c:2642 #3 0x081f84e3 in zend_do_fcall_handler (execute_data=0xbfffd370, opline=0x40298970, op_array=0x82dfa48) at /opt/local/src/lamp/php5-src/Zend/zend_execute.c:2771 #4 0x081f466a in execute (op_array=0x82dfa48) at /opt/local/src/lamp/php5-src/Zend/zend_execute.c:1339 #5 0x081f7f60 in zend_do_fcall_common_helper (execute_data=0xbfffd490, opline=0x40290e54, op_array=0x40290b44) at /opt/local/src/lamp/php5-src/Zend/zend_execute.c:2671 #6 0x081f84e3 in zend_do_fcall_handler (execute_data=0xbfffd490, opline=0x40290e54, op_array=0x40290b44) at /opt/local/src/lamp/php5-src/Zend/zend_execute.c:2771 #7 0x081f466a in execute (op_array=0x40290b44) at /opt/local/src/lamp/php5-src/Zend/zend_execute.c:1339 #8 0x081d1d4d in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /opt/local/src/lamp/php5-src/Zend/zend.c:1053 #9 0x0818e854 in php_execute_script (primary_file=0xbffff8d4) at /opt/local/src/lamp/php5-src/main/main.c:1647 #10 0x08200ded in main (argc=2, argv=0xbffff984) at /opt/local/src/lamp/php5-src/sapi/cli/php_cli.c:941 #11 0x401b7a8e in __libc_start_main (main=0x82002db
, argc=2, argv=0xbffff984, init=0x806e604 <_init>, fini=0x8201c40 <_fini>, rtld_fini=0x4000aa20 <_dl_fini>, stack_end=0xbffff97c) at ../sysdeps/generic/libc-start.c:92 (gdb) In the source code of curl_multi_perform, we can see that it references the readset via the struct Curl_one_easy *easy. Let's see which value the readfdp set has: (gdb) p easy->easy_conn->keep.readfdp $42 = (fd_set *) 0xbfffc720 (gdb) 0xbfffc720 is an address located on the stack of the function zif_curl_multi_select(). Now we look at the value of readfds: (gdb) p /x *easy->easy_conn->keep.readfdp $61 = {__fds_bits = {0x40299d30, 0x4, 0xbfffc748, 0x81db398, 0x825f2d8, 0x4, 0xbfffc744, 0x4030b397, 0x40299cf4, 0x40299d8c, 0xbfffc788, 0x81db4ef, 0x4, 0xbfffc780, 0x2, 0x2, 0x7a, 0x402e458a, 0xbfffc788, 0x0, 0x0, 0x0, 0x82dbee0, 0x82db968, 0x402e59c0, 0x4000aa20, 0xbfffc7c8, 0x402e1ded, 0x82db968, 0xbfffc7b4, 0x402e4551, 0x0}} I cant imagine that this is correct. As the manual states: (man 3 curl_multi_fdset) NOTE that once this call is made, you must not remove the sets you point to, as libcurl will need to be able to read them. It needs them after select() calls, to know if cer­ tain sockets are readable or writable.