Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13061 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10997 invoked by uid 1010); 28 Sep 2004 21:34:57 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 10190 invoked from network); 28 Sep 2004 21:34:51 -0000 Received: from unknown (HELO jan.prima.de) (83.97.50.139) by pb1.pair.com with SMTP; 28 Sep 2004 21:34:51 -0000 Received: from BAUMBART (p508EB461.dip.t-dialin.net [::ffff:80.142.180.97]) (IDENT: HydraIRC, AUTH: LOGIN tobi) by jan.prima.de with esmtp; Tue, 28 Sep 2004 21:34:50 +0000 Date: Tue, 28 Sep 2004 23:32:32 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1487793178.20040928233232@marcus-boerger.de> To: Robert Silva CC: internals@lists.php.net In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit X-Mime-Autoconverted: from 8bit to 7bit by courier 0.43 Subject: Re: [PHP-DEV] Class constants ... possible? From: helly@php.net (Marcus Boerger) Hello Robert, Tuesday, September 28, 2004, 9:01:00 PM, you wrote: > 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. You cannot use ALLOC_ZVAL during PHP_MINIT. If you look at zend_declare_property*() you'll find out how to declare your consts. Maybe we could provide zend_declare_const*() inside the engine. regards marcus > 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 -- Best regards, Marcus mailto:helly@php.net