php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37558 timeout functionality doesn't work after a second PHP starup on the same thread
Submitted: 2006-05-23 08:22 UTC Modified: 2006-05-25 07:47 UTC
From: p dot desarnaud at wanadoo dot fr Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2006-05-23 (snap) OS: win32
Private report: No CVE-ID: None
 [2006-05-23 08:22 UTC] p dot desarnaud at wanadoo dot fr
Description:
------------
On win32 platform, if I try to startup/shutdown PHP several times during the same thread, after the 2nd startup, the timeout functionality doesn't work, and there is an Windows exception (invalid handle) during the 2nd shutdown.

Reproduce code:
---------------
// 1? startup
php_module_startup(...) 
.... 
php_module_shutdown(..)
..
// 2? startup/shutdown
php_module_startup(...) 
// from now the function zend_set_timeout() will not work

Actual result:
--------------
The static variable timeout_thread_initalized declared in the file zend_execute_API.c is not reset to 0 after a shutdown, and so, the next startup will not initialize the timeout thread, and the next shutdown will try to close an invalid handle "CloseHandle(timeout_thread_handle)" inside the function zend_shutdown_timeout_thread(), and I get an exception .

The patch to solve the problem :

--- fix/zend_execute_API.c 2006-04-21 00:49:20.000000000 +0200
+++ zend_execute_API.c 2006-05-23 09:20:38.953125000 +0200
@@ -1339,6 +1339,7 @@
/* Wait for thread termination */
WaitForSingleObject(timeout_thread_handle, 5000);
CloseHandle(timeout_thread_handle);
+ timeout_thread_initialized=0;
}
#endif


But, is it allowed to startup/shutdown several times during the same thread ???
If yes: there is a bug on Win32... If no: there is no bug.. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-25 07:47 UTC] dmitry@php.net
Usually PHP does startup/shutdown secuence only once per process.

php_module_startup/php_module_shutdown shouldn't be called several times.

BTW: you patch is proper. I committed it into CVS HEAD and PHP_5_2.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC