ID:               35612
 Updated by:       [EMAIL PROTECTED]
 Reported By:      alacn dot uhahaa at gmail dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         IIS related
 Operating System: Windows Server 2003
-PHP Version:      5.1.1
+PHP Version:      5CVS-2005-12-20 (snap)
 Assigned To:      dmitry
 New Comment:

Dmitry, can you check this out please.


Previous Comments:
------------------------------------------------------------------------

[2005-12-20 12:38:23] alacn dot uhahaa at gmail dot com

ok.. here is udiff for latest cvs (php5.1)

what is happenning is that since the thread that created the timeout
thread have different access levels than the one that will wait it
finish, waitforsingleobject on timeout thread handle wont work right,
it will always timeout, and access violation will occur

expected: it should return before the timeout, that way wont occur
access violation

the fix: it should wait at least 30 secs, waitforsingleobject will
never elapse all the 30 secs, unless in a bad error,
- it will always return before the 30 secs, as it should -


btw ...cant php4 be fixed too? :(


--- php5.1-200512200930_zend_execute_API.c      Fri Dec 16 21:30:06 2005
+++ php5.1-200512200930_fixed_zend_execute_API.c        Tue Dec 20 08:44:24
2005
@@ -46,7 +46,7 @@
 static WNDCLASS wc;
 static HWND timeout_window;
 static HANDLE timeout_thread_event;
-static HANDLE timeout_thread_handle;
+static HANDLE timeout_thread_finish;
 static DWORD timeout_thread_id;
 static int timeout_thread_initialized=0;
 #endif
@@ -1282,6 +1282,7 @@
        }
        DestroyWindow(timeout_window);
        UnregisterClass(wc.lpszClassName, NULL);
+       SetEvent(timeout_thread_finish);
        return 0;
 }
 
@@ -1289,7 +1290,8 @@
 void zend_init_timeout_thread()
 {
        timeout_thread_event = CreateEvent(NULL, FALSE, FALSE, NULL);
-       timeout_thread_handle = _beginthreadex(NULL, 0, timeout_thread_proc,
NULL, 0, &timeout_thread_id);
+       timeout_thread_finish = CreateEvent(0, 0, 0, 0);
+       _beginthreadex(NULL, 0, timeout_thread_proc, NULL, 0,
&timeout_thread_id);
        WaitForSingleObject(timeout_thread_event, INFINITE);
 }
 
@@ -1302,8 +1304,7 @@
        PostThreadMessage(timeout_thread_id, WM_QUIT, 0, 0);
 
        /* Wait for thread termination */
-       WaitForSingleObject(timeout_thread_handle, 5000);
-       CloseHandle(timeout_thread_handle);
+       WaitForSingleObject(timeout_thread_finish, 30000);
 }
 
 #endif

------------------------------------------------------------------------

[2005-12-19 08:51:01] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip

And this time, really make sure you have the right PHP installed. Only
way to be sure is to delete ALL old dlls related to PHP. Especially
from C:\windows\ directory.
Also, make any patches against the latest CVS sources. PHP 4 is too
old.

------------------------------------------------------------------------

[2005-12-09 19:11:13] [EMAIL PROTECTED]

Fixed in CVS HEAD, PHP_5_1 and PHP_5_0.

------------------------------------------------------------------------

[2005-12-09 12:29:41] alacn dot uhahaa at gmail dot com

Description:
------------
PHP5 and PHP4 on iis6 (windows server 2003) sometimes crash with access
violation

Reproduce code:
---------------
(code at zend_execute_API.c)

before iis shutdown or recycle the pool, it will call
"zend_shutdown_timeout_thread()", that will post a quit message on
"timeout_thread_id" and return


Expected result:
----------------
"zend_shutdown_timeout_thread()" should wait "timeout_thread" finish
before return


Actual result:
--------------
sometimes "zend_shutdown_timeout_thread()" return before the
"tiumeout_thread" finish, and the iis release the library, than the iis
crash at "timeout_thread_proc()" because the library was released.

the fix for PHP5 and PHP4 at "zend_execute_API.c"

"[...]" means hidden code...

#ifdef ZEND_WIN32
#include <process.h>
/* true global */
[...]
// add next line
static HANDLE timeout_thread_finish_event;
#endif

[...]

static unsigned __stdcall timeout_thread_proc(void *pArgs)
{
[...]
DestroyWindow(timeout_window);
UnregisterClass(wc.lpszClassName, NULL);
// add next line
SetEvent(timeout_thread_finish_event);
return 0;
}

void zend_init_timeout_thread()
{
timeout_thread_event = CreateEvent([..]);
// add next line
timeout_thread_finish_event = CreateEvent(0, 0, 0, 0);
[...]
}

void zend_shutdown_timeout_thread()
{
[...]
PostThreadMessage(timeout_thread_id, WM_QUIT, 0, 0);
// add next line
WaitForSingleObject(timeout_thread_finish_event, 30000);
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35612&edit=1

Reply via email to