From: tstarling at wikimedia dot org
Operating system: Windows XP
PHP version: 5.2.3
PHP Bug Type: Filesystem function related
Bug description: exec() deadlocks if another thread is waiting for a file lock
Description:
------------
This appears to be Win32 specific.
The shell execution functions, exec(), passthru(), etc., deadlock if
another thread in the same server is waiting for a file lock.
The most common type of file lock is a lock on a session file, that's
where I saw this first. But I could reproduce it with flock() instead of
session_start().
The typical way for this to manifest itself is if a browser sends two
requests to PHP concurrently, with the same session ID. One request runs
first, the other one blocks waiting for a lock on the session file. Then if
the running request tries to run exec(), it deadlocks and both threads wait
forever.
Tested with both Apache 2.0.54 (mpm_winnt) and 1.3.28. I also had a
colleague confirm it on an independent system.
Reproduce code:
---------------
<?php
if ( isset( $_REQUEST['f'] ) ) {
$f = fopen( 'blah', 'w' );
flock( $f, LOCK_EX );
sleep( 1 );
passthru( "echo Hello" );
} else {
$self = $_SERVER['SCRIPT_NAME'];
echo <<<EOT
<html>
<frameset rows="50%, 50%">
<frame src="$self?f=1"/>
<frame src="$self?f=2"/>
</frameset>
</html>
EOT;
}
?>
Expected result:
----------------
The two frames should both display "Hello", after a delay of 2 seconds.
Actual result:
--------------
The frames take forever to load. Requires a force quit of Apache.
--
Edit bug report at http://bugs.php.net/?id=42064&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42064&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42064&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42064&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42064&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42064&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42064&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42064&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42064&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42064&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42064&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42064&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42064&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42064&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42064&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42064&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42064&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42064&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42064&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42064&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42064&r=mysqlcfg