Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89169 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22759 invoked from network); 11 Nov 2015 03:10:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2015 03:10:39 -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.178 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.160.178 mail-yk0-f178.google.com Received: from [209.85.160.178] ([209.85.160.178:35026] helo=mail-yk0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/BD-21426-DA1B2465 for ; Tue, 10 Nov 2015 22:10:37 -0500 Received: by ykba77 with SMTP id a77so29806426ykb.2 for ; Tue, 10 Nov 2015 19:10:34 -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=5wFqoY3hJW1qyedO3fbrEj1ofi7KCJ9gOAa5/IFeRMc=; b=c86KFvigrBShi4ox3F1KNfnJYVwrcZ2G5ux9hI3SJXh/YDdG6N+AxCRO8DSJVxLbaG ygofHJ4ZTAyyYDYjKBuFIpFzzPKxJwYUwANzwvg3JUz3nfZLuBdFUx1Ip1hMkONSkmap N0zbReQAy3MykW7mWHbMAWw3tiHt7NAy5FudPlT5Lns94jCPh6Q1Vnm5ZZgzh2KkHGM0 zZFMV/mw5kakgAMIPVcwKVgdJ+lXnwIMvJ5eO7V9ACbvbcVQ0n1t0pGaElcBv6QqFfnA fMb4iX8xapZfqSXlZA1O5J4U5hfUrlMkdwQ8HWc49B5igjYS7eGTEKeirpbcM3M4hWYJ JzGg== 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=5wFqoY3hJW1qyedO3fbrEj1ofi7KCJ9gOAa5/IFeRMc=; b=P5yK14kB3T8D8EUCzfqtAbyA+l2SQFd2JjBB2jLE3gT4TU+KR8zbICQbL/K9aTSfrt UR4Ty07AhzSjB16KbRJnwqxFnqQ7t1JzHqZO1ja8WfwCKcQ7glcsCL7oDX+wFtWMCXO4 1OISNWA0nt0wSznLn/INletUR8NEI+kHzlSnLYsrqQmx/XVJ3divv34avazfTC4NTMkP NpCXp2WmkZ5IDXxmJz1xzlKpAUDJ9WZFkv1b+2Qugl9zORSUXcUObLmb6b2LZtYoDLBF qik0EyA94vWzdkZTN+sxrImHGL0KcQudyuYorFKLH1IBLHjhwedbXJsHL0756Px/8MBE WMAg== X-Received: by 10.13.228.4 with SMTP id n4mr7934213ywe.228.1447211434438; Tue, 10 Nov 2015 19:10:34 -0800 (PST) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.31.229.193 with HTTP; Tue, 10 Nov 2015 19:10:15 -0800 (PST) In-Reply-To: References: Date: Wed, 11 Nov 2015 11:10:15 +0800 X-Google-Sender-Auth: HwqIC02NkPrDnx7EIp2Rs1fQGxY Message-ID: To: Dmitry Stogov Cc: Nikita Popov , Bob Weinand , PHP Internals Content-Type: multipart/alternative; boundary=94eb2c03586076fb4605243b2b0d Subject: Re: Safe Temporary Cleanup on Exception (Variable Liveness) From: xinchen.h@zend.com (Xinchen Hui) --94eb2c03586076fb4605243b2b0d Content-Type: text/plain; charset=UTF-8 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 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/ --94eb2c03586076fb4605243b2b0d--