Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38265 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19019 invoked from network); 16 Jun 2008 02:55:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jun 2008 02:55:15 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:54961] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/F1-06776-216D5584 for ; Sun, 15 Jun 2008 22:55:14 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id 30941C13221 for ; Sun, 15 Jun 2008 19:55:18 -0700 (MST) Received: from [192.168.0.106] (CPE-76-84-4-101.neb.res.rr.com [76.84.4.101]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id AC7ABC1321C for ; Sun, 15 Jun 2008 19:55:17 -0700 (MST) Message-ID: <4855D62C.2010902@chiaraquartet.net> Date: Sun, 15 Jun 2008 21:55:40 -0500 User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: internals Mailing List X-Enigmail-Version: 0.95.0 Content-Type: multipart/mixed; boundary="------------060508090507070301060505" X-Virus-Scanned: ClamAV using ClamSMTP Subject: potential shutdown order issue From: greg@chiaraquartet.net (Gregory Beaver) --------------060508090507070301060505 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, I'm getting errors of hashtable already destroyed when running phpMyAdmin with PHP 5.3, and (of course), thinking this is a phar issue, I've traced through and found a problem in the shutdown order. Basically, php_request_shutdown() calls zend_deactivate() which calls zend_destroy_rsrc_list(&EG(regular_list)). On the next line, zend_post_deactivate_modules() is called, which steps through the module list and unloads all the dynamically loaded modules. If one of these modules (like mysqli) declares a resource type, then in module_destructor() zend_clean_module_rsrc_dtors() is called, which calls zend_clean_modules_rsrc_dtors_cb() (zend_list.c:253). This function then walks over EG(regular_list), which had been previously destroyed. I think this issue could be fixed by moving the zend_destroy_rsrc_list(&EG(regular_list)) call after the module shutdown. I've attached a patch demonstrating the principle (this fixes the hashtable destroyed message and I don't get anything bad like a segfault). Could someone with more brains double-check this one? I think it can be reproduced with a debug build using mysqli loaded dynamically and any script that uses mysqli, but I've only reproduced it with phpMyAdmin. Thanks, Greg --------------060508090507070301060505 Content-Type: text/plain; name="fix_shutdown.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fix_shutdown.patch.txt" Index: Zend/zend.c =================================================================== RCS file: /repository/ZendEngine2/zend.c,v retrieving revision 1.308.2.12.2.35.2.18 diff -u -r1.308.2.12.2.35.2.18 zend.c --- Zend/zend.c 29 Apr 2008 08:15:16 -0000 1.308.2.12.2.35.2.18 +++ Zend/zend.c 16 Jun 2008 02:53:00 -0000 @@ -901,7 +901,8 @@ shutdown_compiler(TSRMLS_C); } zend_end_try(); - zend_destroy_rsrc_list(&EG(regular_list) TSRMLS_CC); + /* shutdown order issue */ + /* zend_destroy_rsrc_list(&EG(regular_list) TSRMLS_CC); */ #ifdef ZEND_DEBUG if (GC_G(gc_enabled) && !CG(unclean_shutdown)) { Index: main/main.c =================================================================== RCS file: /repository/php-src/main/main.c,v retrieving revision 1.640.2.23.2.57.2.22 diff -u -r1.640.2.23.2.57.2.22 main.c --- main/main.c 21 May 2008 15:55:31 -0000 1.640.2.23.2.57.2.22 +++ main/main.c 16 Jun 2008 02:53:02 -0000 @@ -1527,6 +1527,8 @@ zend_post_deactivate_modules(TSRMLS_C); } zend_end_try(); + zend_destroy_rsrc_list(&EG(regular_list) TSRMLS_CC); + /* 9. SAPI related shutdown (free stuff) */ zend_try { sapi_deactivate(TSRMLS_C); --------------060508090507070301060505--