Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18539 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7858 invoked by uid 1010); 29 Aug 2005 22:13:25 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 7843 invoked from network); 29 Aug 2005 22:13:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Aug 2005 22:13:25 -0000 X-Host-Fingerprint: 69.12.155.130 69-12-155-130.dsl.static.sonic.net Linux 2.4/2.6 Received: from ([69.12.155.130:1557] helo=pigeon.alphaweb.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 24/DE-15098-58883134 for ; Mon, 29 Aug 2005 18:13:25 -0400 Received: from localhost ([127.0.0.1] helo=peiscg33m) by pigeon.alphaweb.net with smtp (Exim 4.10) id 1E9rEz-00041l-00 for internals@lists.php.net; Mon, 29 Aug 2005 14:32:29 -0700 Message-ID: <011d01c5ace6$de33a7f0$5c8be5a9@ohr.berkeley.edu> Reply-To: "Sara Golemon" To: Date: Mon, 29 Aug 2005 15:13:01 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 Subject: ZTS leak From: pollita@php.net ("Sara Golemon") In looking into a series of leaks regarding tsrm interpreter contexts with George and Wez, we came across a problem with how EG(zend_constants) is created and destroyed. Specifically it's only destroyed once, from zend_shutdown(). However it's created by executor_globals_ctor(). In non-ZTS this isn't a problem since egctor is only called the one time during startup, however when ZTS is enabled egctor gets called repeatedly (including once for every request startup) and the allocated EG(zend_constants) is leaked over and over again. Of lesser criticality (but no less important) rsrc_plist is also leaked by this unbalanced positioning. I temporarily plugged the constants leak (90k+ per request) by using the patch below (though it's inefficient for obvious reasons), but rsrc_plist will take a slightly different approach (heading out the door now so no time to think it through). There's also a 200 byte leak in the thread key, but that's once per engine and not a per-request issue so I'm even less concerned about that one. -Sara Index: Zend/zend.c =================================================================== RCS file: /repository/ZendEngine2/zend.c,v retrieving revision 1.308 diff -u -r1.308 zend.c --- Zend/zend.c 3 Aug 2005 13:30:45 -0000 1.308 +++ Zend/zend.c 29 Aug 2005 21:40:13 -0000 @@ -486,6 +486,7 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS_DC) { zend_ini_shutdown(TSRMLS_C); + zend_shutdown_constants(TSRMLS_C); } @@ -706,7 +707,6 @@ zend_shutdown_extensions(TSRMLS_C); free(zend_version_info); - zend_shutdown_constants(TSRMLS_C); free(GLOBAL_FUNCTION_TABLE); free(GLOBAL_CLASS_TABLE); #ifdef ZTS