Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89170 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23933 invoked from network); 11 Nov 2015 03:11:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2015 03:11:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.175 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.160.175 mail-yk0-f175.google.com Received: from [209.85.160.175] ([209.85.160.175:35724] helo=mail-yk0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/FD-21426-CD1B2465 for ; Tue, 10 Nov 2015 22:11:24 -0500 Received: by ykba77 with SMTP id a77so29829850ykb.2 for ; Tue, 10 Nov 2015 19:11:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=S6CInyTmT6pgUCF1nIFXP5j+f3CV8cuCqkuj/oMkaXQ=; b=IfrLzgcsEav+twzduN4/IXfD1FcHM2SIej4vgv339kPRWoVKDxItNEmh2jvTgOpyhk jmRRDfXvS8XPDKOlvXkcJjYY/h7QmTrglk0RvNakqpQScGL0hv79TeYoeuVCkXOxYnqm 7UztkYhy50+j3bqQXQFLbQv9+LiVbjWo4eMT4WLgioYWhRIBKvoPosphdCzNSO/JfDtO eBYVpASAYsBnZrCB1f5I+Sq8CFQ1rYFTHfv6kMy8+shmXMM+B3xOauRRefg8iAHvCsf3 HXdcFlfbv1IvQ2DeuAFcOq++eTTG1+yGf6kz9bsRN75VepMw446HbkKioV5JWPJXFQoX 1ElQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zend_com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=S6CInyTmT6pgUCF1nIFXP5j+f3CV8cuCqkuj/oMkaXQ=; b=wpkweFhM5zWW04Zc3Kg5FX4CtUB7P4qQ9AnYP7U5pXHBT9takzWK4QtM2wz6Vt5cLm RtDWH1YwVuKw0fFAgVmY/4a8yotXx5e+6opl4pp4pm1++kg+l/GArBLZu2yOT01Btu/F B8iTWYh6R0/yXJPRixAFv0U2Xd54s7hvftD/AN7bFawTv8nRrJQNjLkk9FayrcCOyIhO IMEq10b6bHv5HrOUyR7aKZwJjVNkqgthEJWdILAaNbTWTVLFoBNaKtTeg4xXfRPkxjLi foz8vp++KhcMIX2NzQl0VUFlwiU839cy8oQueVYVcTYUS5/3N6eRJh3U0drOMTmOO3SB Rp5w== X-Received: by 10.13.215.204 with SMTP id z195mr7403965ywd.222.1447211482072; Tue, 10 Nov 2015 19:11:22 -0800 (PST) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.31.229.193 with HTTP; Tue, 10 Nov 2015 19:11:02 -0800 (PST) In-Reply-To: References: Date: Wed, 11 Nov 2015 11:11:02 +0800 X-Google-Sender-Auth: pHqlSB8En5PsYS-KcQcrb_TPNv8 Message-ID: To: Dmitry Stogov Cc: Nikita Popov , Bob Weinand , PHP Internals Content-Type: multipart/alternative; boundary=94eb2c0bd7b44dcf7805243b2e5e Subject: Re: Safe Temporary Cleanup on Exception (Variable Liveness) From: xinchen.h@zend.com (Xinchen Hui) --94eb2c0bd7b44dcf7805243b2e5e Content-Type: text/plain; charset=UTF-8 On Wed, Nov 11, 2015 at 11:10 AM, Xinchen Hui wrote: > Hey: > > On Tue, Nov 10, 2015 at 7:29 PM, Dmitry Stogov wrote: > >> >> >> On Tue, Nov 10, 2015 at 1:42 PM, Nikita Popov >> wrote: >> >>> On Tue, Nov 10, 2015 at 10:53 AM, Dmitry Stogov wrote: >>> >>>> Hi, >>>> >>>> Please take a look into >>>> https://gist.github.com/dstogov/43eaa3f3b68583877322 >>>> >>>> This is variation on Bob's idea about variable liveness. >>>> The patch is incomplete. Liveness construction is still naive. However, >>>> all tests are passed. >>>> >>>> Ranges are represented by start/end/variable cartages. (I suppose this >>>> representation is more compact, than in the original proposal). >>>> In general, it's possible to use few ranges for the same variable, if >>>> its whole live range is not linear. (this is not implemented yet). >>>> >>>> Related ideas and tests are welcome. >>>> >>>> Thanks. Dmitry. >>>> >>> >>> One leak this does not cover yet is a discarded delayed return value: >>> >>> function test() { >>> try { >>> $a = [1, 2, 3]; >>> return $a + []; >>> } finally { >>> throw new Exception; >>> } >>> } >>> >>> try { >>> test(); >>> } catch (Exception $e) {} >>> >>> This case is a bit tricky because it violates the usual invariant that >>> all temporaries have well-defined liveness ranges (either alive or not, no >>> maybe). We'd have to change that first. >>> >> >> I see the problem. We can't statically define live-ranges for finally >> code, because we don't know where it's going to be called from. >> May be we may reconstruct this at run-time. >> > Or maybe we could separate ZEND_RETURN(_BY_REF) into two parts > > the first part, set the return value to EX(return_value), the second part > do the really leave(leave_helper). > > thus, we can keep the liveness of the variable won't be intrruptted? > > like: previously we emit: ZEND_ADD, ZEND_FAST_CALL, ZEND_RETURN. > > now we emit: ZEND_ADD, ZEND_RETURN, ZEND_FAST_CALL, ZEND_RETURN > s #ZEND_RETURN$#ZEND_LEAVE# thanks > > then in HANDLE_EXCEPTION we can dtor EX(return_value) if it is > already set? > > this could also fixed double return memory leak > like Zend/tests/try/bug70228.phpt > > thanks > >> >> Thanks. Dmitry, >> >> >> >>> >>> Nikita >>> >>> >> > > > -- > Xinchen Hui > @Laruence > http://www.laruence.com/ > -- Xinchen Hui @Laruence http://www.laruence.com/ --94eb2c0bd7b44dcf7805243b2e5e--