php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24390 persistent resources destructors aren't called when ZTS is enabled.
Submitted: 2003-06-29 14:54 UTC Modified: 2004-03-15 08:43 UTC
From: vaclav dot pecuch at tiscali dot cz Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4CVS, 5CVS OS: any (+ ZTS)
Private report: No CVE-ID: None
 [2003-06-29 14:54 UTC] vaclav dot pecuch at tiscali dot cz
Description:
------------
PHP 4.3.2 on Windows doesn't call persistent resource destructors on PHP process shutdown.

I'm using persitent resources in my PHP module, i.e.

in MINIT function I register destructors for my resources:
	mymod_rsc=zend_register_list_destructors_ex(mymod_commit_rsc, mymod_close_rsc, MYMOD_RSC_NAME, module_number);

I add newly created resource to EG(persistent_list) by this code
list_entry new_le;
Z_TYPE(new_le) = mymod_rsc;
new_le.ptr = malloced_rsc_data_buffer;
zend_hash_update(&EG(persistent_list), hashed_details, strlen(hashed_details)+1, (void *) &new_le, sizeof(list_entry), NULL);

Function mymod_commit_rsc is called at the end of the request while mymod_close_rsc is never called.

I'm running PHP 4.3.2 with Apache 1.3.27 (PHP runs as Apache module) on Windows 2000. I'm loading PHP module through "extension" directive in PHP.INI. I've tested my module on Linux (RH 7.3, PHP 4.3.2 as Apache module with Apache 1.3.27) and it worked - mymod_close_rsc was called at the end of PHP process or more precisely at the end of Apache process.


Reproduce code:
---------------
The simplest example is there: http://home.tiscali.cz/vaclav.pecuch/phptestmodule.zip

This is PHP module which registers its persistent resource in MINIT function, implements "create_resource" function and contains some logging (ugly but functional).

Change path settings in makefile and logfile path and filename  in C source before build.

Expected result:
----------------
Destruction of persistent resources at the end of PHP process.

Actual result:
--------------
Destructor isn't called on Windows, is called on Linux.

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-29 21:07 UTC] sniper@php.net
This is not Windows specific, but ZTS issue.
The persistant resource destructor is not called at all when ZTS is enabled. (tested using CLI compiled with ZTS enabled)

Test sources found here (a bit cleaned up version):

  http://www.php.net/~jani/ext_tm.tar.gz

Configure php:

# ./configure --disable-all --disable-cgi --enable-tm --enable-experimental-zts

Test results:
-----------------------------------------------------------
Thread Safety => disabled

resource(4) of type (TestModule Resource)
TestModule (normal): resource "non-persistent resource" created
(non-persistent) Running tm_resource_dtor() for resource "non-persistent resource"

resource(4) of type (TestModule Persistent Resource)
TestModule (persistent): resource "persistent resource" created
(persistent): Running tm_presource_dtor() for resource "persistent resource"

-----------------------------------------------------------
Thread Safety => enabled

resource(4) of type (TestModule Resource)
TestModule (normal): resource "non-persistent resource" created
(non-persistent) Running tm_resource_dtor() for resource "non-persistent resource"

resource(4) of type (TestModule Persistent Resource)
TestModule (persistent): resource "persistent resource" created

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



 [2003-07-27 12:31 UTC] iliaa@php.net
Not only do the persistent resources destructors are not called, but the MSHUTDOWN is also not called resulting in quite a few memory leaks.
 [2004-02-26 15:29 UTC] sniper@php.net
See also bug #27185 (these two are propably same issue)
 [2004-02-26 15:30 UTC] sniper@php.net
The MSHUTDOWN _is_ called in both zts/non-zts modes.

 [2004-03-15 08:43 UTC] sniper@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Aug 17 16:01:29 2024 UTC