#42064 [Opn->Fbk]: exec() deadlocks if another thread is waiting for a file lock

From: Date: Sun, 22 Jul 2007 15:30:05 +0000
Subject: #42064 [Opn->Fbk]: exec() deadlocks if another thread is waiting for a file lock
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115302@lists.php.net to get a copy of this message
ID: 42064 Updated by: jani@php.net Reported By: tstarling at wikimedia dot org -Status: Open +Status: Feedback Bug Type: Filesystem function related Operating System: win32 only PHP Version: 5.2.3 New Comment: Isn't this just expected behaviour if you're not checking whether the flock call fails or not?? Previous Comments: ------------------------------------------------------------------------ [2007-07-22 02:50:03] tstarling at wikimedia dot org 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 this bug report at http://bugs.php.net/?id=42064&edit=1

« previous php.bugs (#115302) next »