Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88751 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20704 invoked from network); 12 Oct 2015 18:24:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Oct 2015 18:24:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.52 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.52 mail-vk0-f52.google.com Received: from [209.85.213.52] ([209.85.213.52:36687] helo=mail-vk0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/30-16518-6FAFB165 for ; Mon, 12 Oct 2015 14:24:55 -0400 Received: by vkgc187 with SMTP id c187so27270926vkg.3 for ; Mon, 12 Oct 2015 11:24:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=oDUL0pwwbRWxGZ1FAqCOQBtIE+y4UN2cu/0Ww7IH3+4=; b=GvD0sXF7IZgMpzmx3oYtt04c55QhXvXuXZhIKegFRjjKsCLjEnNLZN8UrZmUyYtgLm e+2Pui7F4vzHcZPqVzSN8EfOdtiOmyR61hwP9wQMN6RpYffMcH5VcLfB/9AN6yaoulmM 5qqgWpXJLxC7JA6mZYNND1qjKDhsxrrxBgQs0KLsYtUgWw+ryhhnQOlT7k96/lSlyyqq hUV1LpY+oAjOYlBDKpX7C5c2ujhWxdT6o855CTt3eG/veerK38OKFHPKHW3A0XnKqq80 NCakv/FaWNALJddFW1pZA+BEV0zHq4QfYmTAa+SvyxqpuaCiQxMNTyg8xDxsya2Fw1yB P8BQ== X-Gm-Message-State: ALoCoQkrodmIYd0UkMkdj8sExGKBCLYncFwu33eR+rpxBxbJmC+jhLNJ5OZDIWQAC2pA15frtlN3I06oJWj9Uy75cS6D0e8yqgnu0+2r9qJYOrkZSPMIzi0ex5vOt/WKTxvW4VyiYjQEPqy8hbuC49bHHbHXcTWsw7a9WgEfLCgB9BOKrS5gOIo= MIME-Version: 1.0 X-Received: by 10.31.158.205 with SMTP id h196mr19329408vke.11.1444674291804; Mon, 12 Oct 2015 11:24:51 -0700 (PDT) Received: by 10.103.24.5 with HTTP; Mon, 12 Oct 2015 11:24:51 -0700 (PDT) In-Reply-To: References: Date: Mon, 12 Oct 2015 21:24:51 +0300 Message-ID: To: Nikita Popov Cc: PHP internals , Andrea Faulds , Stas Malyshev , Bob Weinand , Anatol Belski Content-Type: multipart/alternative; boundary=001a11415a8efac6190521ec712a Subject: Re: Forbid rebinding scope of closures created by ReflectionFunctionAbstract::getClosure() From: dmitry@zend.com (Dmitry Stogov) --001a11415a8efac6190521ec712a Content-Type: text/plain; charset=UTF-8 Hi Nikita, I think the effect of the remaining patch is negligible. It disables things, that shouldn't work by design, didn't work in fact and leaded to crashes. It might work only in some cases and only because of luck. So, I think it's better to commit this before next RC. Anatol is going to start rolling it on Tuesday. He will also increase all API version numbers. It would be great, if we stop any commits into PHP-7.0 except for critical fixes now Thanks. Dmitry. On Sat, Oct 10, 2015 at 4:26 PM, Nikita Popov wrote: > Hi internals! > > We have recently been reviewing the interaction between > ReflectionFunctionAbstract::getClosure(), a mechanism which converts an > ordinary function or method into a "fake" closure, and closure rebinding > using Closure::bindTo() and Closure::call(). > > It turns out that this combination has not yet received testing and > multiple crashes and leaks were found and fixed [1] [2] [3] [4]. > > We have one last outstanding changeset [5] waiting to land, which we want > to check back with internals first, as it constitutes a BC break late in > the PHP 7.0 release cycle. > > This changeset forbids rebinding the *scope* of closures returned by > getClosure() completely. The background of this change is that PHP 7 > includes optimizations that early-bind the scope of self:: during > compilation (and there are more optimizations of this nature pending to > land in PHP 7.1). This means that attempts to change the meaning of "self" > in an ordinary method at runtime will not always succeed and lead to > inconsistent results. > > Based on feedback received on an earlier version of this patch [6] [7], we > have not added any additional restrictions on rebinding of $this. > getClosure()s of userland methods can still be bound to arbitrary $this > values and getClosure()s of internal methods can still be bound to > "compatible" $this values. (If someone sees a problem with allowing the > former, please speak up!) > > Note that all this applies to ReflectionFunctionAbstract::getClosure() > only. Rebinding behavior of ordinary closures doesn't change. > > It would be appreciated if some more people familiar with the closure > implementation could take a look at our rebinding rules and see if there's > any situations that aren't covered yet and could be problematic. > > Thanks, > Nikita > > [1] https://bugs.php.net/bug.php?id=70630 > [2] https://bugs.php.net/bug.php?id=70674 > [3] https://bugs.php.net/bug.php?id=70681 > [4] https://bugs.php.net/bug.php?id=70685 > [5] https://github.com/php/php-src/pull/1560 > [6] > https://github.com/php/php-src/commit/517b5536259ecf7697f353f4bfbafde857fc1f81 > [7] > https://github.com/php/php-src/commit/881c50252066132f83e190325e344f532be19033 > --001a11415a8efac6190521ec712a--