Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76976 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68740 invoked from network); 31 Aug 2014 04:18:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Aug 2014 04:18:18 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.41 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.220.41 mail-pa0-f41.google.com Received: from [209.85.220.41] ([209.85.220.41:56056] helo=mail-pa0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/F1-50403-902A2045 for ; Sun, 31 Aug 2014 00:18:17 -0400 Received: by mail-pa0-f41.google.com with SMTP id lj1so9448309pab.14 for ; Sat, 30 Aug 2014 21:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=J1jnnRqv7smHInyvvlLrV56z3XTJbeT6W7Kuan8O8ro=; b=CB36I4Eq96+Gb3bDa0eWALjSvipzvi+cbaIRxcDaQFtTrz+XdbAcm5GzsQhS3fngqb vRw/+Lp/n0h8CTjjT/7Jy3OqiEcnGXxC3N8L1gnhXHLPeAeYu7nghfoa45herhj33lBG N4oawjoEoBQCWwY2LXbGT+xO3S3CIKpHEYZmC332e4trH7uO0H0WPMoHIeF+ZAVfLM6L ncR7yWMwKKFpaLBAd/evHrgmysgm1HYif7n0YYc4DRnEMtcopUwYMcZ4paarLdrpE25c xbF3aGmmFMkDnPJpxqbVOkUcaLHduoQttdK9D/KhZCZu5TGpf2BZo/yN8yiEfeoXRtG5 kazQ== X-Received: by 10.66.222.74 with SMTP id qk10mr28514093pac.70.1409458694636; Sat, 30 Aug 2014 21:18:14 -0700 (PDT) Received: from [192.168.1.102] (bb121-7-198-24.singnet.com.sg. [121.7.198.24]) by mx.google.com with ESMTPSA id ci1sm4167604pbb.68.2014.08.30.21.18.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Aug 2014 21:18:13 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: <54027B6D.7060708@sugarcrm.com> Date: Sun, 31 Aug 2014 12:18:08 +0800 Cc: PHP Internals , jocelyn fournier , Dmitry Stogov Content-Transfer-Encoding: quoted-printable Message-ID: References: <54027B6D.7060708@sugarcrm.com> To: Stanislav Malyshev X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] destructors and output_buffering From: tjerk.meesters@gmail.com (Tjerk Meesters) On 31 Aug, 2014, at 9:33 am, Stas Malyshev = wrote: > Hi! >=20 > I was looking at bug https://bugs.php.net/bug.php?id=3D67644 and it = looks > like we have a bit of a problem with output buffering and dtors on > shutdown. Basically, right now our code looks like this: >=20 > /* 2. Call all possible __destruct() functions */ > zend_try { > zend_call_destructors(TSRMLS_C); > } zend_end_try(); >=20 > /* 3. Flush all output buffers */ > zend_try { > =09 > // And here we go flushing output buffers >=20 > Now, since ob functions can have userland handlers, these handlers can > create new objects. And these objects will not benefit from orderly = dtor > round that zend_call_destructors(TSRMLS_C) is providing - instead = their > dtors will be called from zend_objects_store_free_object_storage() and > by then their environment may already be ruined and their dtors can = not > run properly. >=20 > OTOH, moving __destruct after output buffers may not be good either, = as > dtors may output something. >=20 > The problem seems to be resolved if I either duplicate > zend_call_destructors(TSRMLS_C); after the output buffers flushing or = put > zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC); > there. >=20 > Of course, the second solution has the downside of not calling the = dtors > of objects that were created while flushing ob buffers. The > zend_call_destructors would work but since output buffering is = supposed > to be shut down by then, I wonder if it won't also have bad = consequences > if these dtors do something with output buffering. >=20 > I'm leaning towards the second solution - if you create the objects so > late on shutdown stage, you shouldn't really expect them to be = destroyed > normally, otherwise the cycle would never end. However, we could > consider the first option too. Any thoughts? This is just a thought; could we delay the call to = `zend_call_destructors` ONLY IF there=92s output buffering taking place = (i.e. ob_get_level() > 0)? > --=20 > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20