#47540 [NEW]: CLI can go into an infinite write() loop when ignore_user_abort(true)

From: Date: Mon, 02 Mar 2009 04:01:46 +0000
Subject: #47540 [NEW]: CLI can go into an infinite write() loop when ignore_user_abort(true)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-134306@lists.php.net to get a copy of this message
From: tstarling at wikimedia dot org Operating system: Linux PHP version: 5.2CVS-2009-03-02 (CVS) PHP Bug Type: *General Issues Bug description: CLI can go into an infinite write() loop when ignore_user_abort(true) Description: ------------ sapi_cli_ub_write() is faulty and may go into a tight infinite loop under certain circumstances. If write() produces an error, it calls php_handle_aborted_connection(), but if ignore_user_abort(true) has been called, this does not exit the request. Thus it enters an infinite loop. Bug #20053 is a similar bug in a different SAPI. It's likely that many SAPIs have copied this code and suffer the same problem. Reproduce code: --------------- <?php ignore_user_abort(true); while ( true ) { fwrite( STDERR, microtime(true) . "\n" ); echo "Hello\n"; usleep(500000); } ?> Run it like this: $ php nfs-test.php > /mnt/some-nfs-mount/test-file Then while that is running, on another server: $ rm /mnt/some-nfs-mount/test-file Expected result: ---------------- It should exit when the file is removed, like it does when ignore_user_abort(true) is not called. Actual result: -------------- After a few seconds, the stderr output will stop ticking, and strace will show a flood of: write(1, "Hello\n", 6) = -1 ESTALE (Stale NFS file handle) write(1, "Hello\n", 6) = -1 ESTALE (Stale NFS file handle) write(1, "Hello\n", 6) = -1 ESTALE (Stale NFS file handle) write(1, "Hello\n", 6) = -1 ESTALE (Stale NFS file handle) write(1, "Hello\n", 6) = -1 ESTALE (Stale NFS file handle) write(1, "Hello\n", 6) = -1 ESTALE (Stale NFS file handle) -- Edit bug report at http://bugs.php.net/?id=47540&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47540&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47540&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47540&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47540&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47540&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47540&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47540&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47540&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47540&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47540&r=support Expected behavior: http://bugs.php.net/fix.php?id=47540&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47540&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47540&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47540&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47540&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47540&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47540&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47540&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47540&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47540&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47540&r=mysqlcfg

« previous php.bugs (#134306) next »