ID: 42682 Comment by: margus at zone dot ee Reported By: Slig at free dot fr Status: Open Bug Type: Streams related Operating System: linux-64 PHP Version: 5CVS-2007-09-16 (snap) New Comment:
I was hit by the same annoying bug (CentOS 4.5/x64/PHP5.1.6 & 5.2.3) After debugging PHP stream_select() I found out that system's select() returns correct number but this value get's mysteriously set to zero (memory is overwritten?) a few steps before returning it to PHP script. Anyway, the cure for me was to change an variable type from int to long and explicitly reset it to 0. This patch works for both PHP 5.1 and 5.2: --- ext/standard/streamsfuncs.c.orig 2007-10-09 16:21:30.000000000 +0300 +++ ext/standard/streamsfuncs.c 2007-10-09 16:21:41.000000000 +0300 @@ -608,7 +608,7 @@ zval **elem, **dest_elem; php_stream *stream; HashTable *new_hash; - int this_fd, ret = 0; + long this_fd = 0, ret = 0; if (Z_TYPE_P(stream_array) != IS_ARRAY) { return 0; Previous Comments: ------------------------------------------------------------------------ [2007-10-11 16:29:15] Slig at free dot fr Sorry, still the same with the last snapshot on amd64/dual core xeon on debian etch : it works without --with-openssl but don't work when built using --with-openssl :( ------------------------------------------------------------------------ [2007-10-11 13:51:17] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows (zip): http://snaps.php.net/win32/php5.2-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.2-win32-installer-latest.msi ------------------------------------------------------------------------ [2007-09-21 00:06:00] Slig at free dot fr I tested today on a dual dual-core-xeon on current Fedora 7 x86_64, first with current php and current openssl, then building php6 from the source : same result, it give the expected result without openssl, but return 0 when build with --with-openssl when there is a descriptor to read. Note: If i use as workaround 'while($nb>0 || count($r)>0){' and reduce the read buffer ( fread($handle,30); for example), then i see that after the first read the value returned by stream_select is ok... but it shows another bug (#42720) :d ------------------------------------------------------------------------ [2007-09-19 08:26:27] Slig at free dot fr OpenSSL on the tested computer: Architecture: amd64 , Version: 0.9.8c-4 I can try only on the same server with a different cpu (dual core xeon and not quad core xeon) and another distro, but not sure when i'll have time for that, i'll tell you the result here. ------------------------------------------------------------------------ [2007-09-18 09:40:37] [EMAIL PROTECTED] I still can not reproduce this on my system. OpenSSL Version => OpenSSL 0.9.8b 04 May 2006 Are you able to reproduce this on more than one machine? (and with other linux distro than debian) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/42682 -- Edit this bug report at http://bugs.php.net/?id=42682&edit=1