Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13058 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34997 invoked by uid 1010); 28 Sep 2004 19:00:57 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 34952 invoked from network); 28 Sep 2004 19:00:56 -0000 Received: from unknown (HELO bobsilva.com) (198.237.84.92) by pb1.pair.com with SMTP; 28 Sep 2004 19:00:56 -0000 Received: from [198.237.84.90] (account me HELO salty) by bobsilva.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 440988 for internals@lists.php.net; Tue, 28 Sep 2004 11:38:18 -0700 To: Date: Tue, 28 Sep 2004 12:01:00 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Thread-Index: AcSljX4ZNQYHxMV+TMitlO/dxrhYbg== Message-ID: Subject: Class constants ... possible? From: junkmail@bobsilva.com ("Robert Silva") After 3 days tracing this thing, I found the problem. Any suggestions? Im trying to define a class constant by allocating a zval str using ALLOC_ZVAL in PHP_MINIT for my extension. This class constant is applied to the class and works as expected. The problem comes during shutdown. In php_request_shutdown --> shutdown_memory_manager, it detects the ZVAL that the constant was stored in as a "leak" and frees the zval. This causes PHP to crash during tsrm_shutdown when it starts destroying classes. Is it expected for a variable allocated during module init to be freed during request shutdown? Below is the trace of the class destruction (after the memory manager already freed my zval in the class_constants ht. The first line here is freeing the zval associated with the constants key in the class_entry->constants_table (which has already been freed). php5ts_debug.dll!_zval_internal_ptr_dtor(_zval_struct * * php5ts_debug.dll!_zval_internal_ptr_dtor_wrapper(_zval_struct * * php5ts_debug.dll!zend_hash_destroy(_hashtable * ht=0x009827cc) Line 521 + php5ts_debug.dll!destroy_zend_class(_zend_class_entry * * pce=0x009e3de4) php5ts_debug.dll!zend_hash_destroy(_hashtable * ht=0x009e32d8) Line 521 + php5ts_debug.dll!compiler_globals_dtor(_zend_compiler_globals * php5ts_debug.dll!tsrm_shutdown() Line 164 + 0x21 C php.exe!main(int argc=4, char * * argv=0x00902508) Line 1056 + 0x8 C php.exe!mainCRTStartup() Line 398 + 0x11 C kernel32.dll!77e814c7() And here is my the call stack when it frees the memory: e:\php5\php5cvs\php5\ext\bfl\bfl_system.c(332) : Freeing 0x00920728 (16 bytes), script=test.php php5ts_debug.dll!shutdown_memory_manager(int silent=0, int full_shutdown=0, php5ts_debug.dll!php_request_shutdown(void * dummy=0x00000000) Line 1227 + php.exe!main(int argc=4, char * * argv=0x00902508) Line 1046 + 0xa C php.exe!mainCRTStartup() Line 398 + 0x11 C kernel32.dll!77e814c7() So is it possible to define a class constant during MINIT? If so how. Use a module global? Thanks Bob