Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75024 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52967 invoked from network); 20 Jun 2014 17:46:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2014 17:46:30 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.172 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.172 mail-qc0-f172.google.com Received: from [209.85.216.172] ([209.85.216.172:37151] helo=mail-qc0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B1/00-52792-47374A35 for ; Fri, 20 Jun 2014 13:46:28 -0400 Received: by mail-qc0-f172.google.com with SMTP id o8so3861372qcw.3 for ; Fri, 20 Jun 2014 10:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=onnZJSXggHtuEVdjnsbU8+dHWajTScMG0pjgM7pZ078=; b=O2YpMS8FSEKB77kBoQ7CbA+oHtkOsw+cZMr4CpU1owcKJeD3+xl8gr2IZc9xxsmXLv RDyCI/J1Gri0G2Q0eXN5d+gcXezNZYk2otJ3EwkwhkTrG9XPQhn5O0E3SDpqx94K0zR6 kUxDRfHZCrmw+AzzuzyWJnvarn2SI9m40vgUw/B+sFmNQDXhOfo9l14LXH+ymSub8sXi nKa1j0OLWUr0CP4azKqLE+LMlMWBjr3E/4aBVLZ7LsjNb0bT7HcJp1qPrB5v368c64n4 57dOfLqo4xPm+cyOqrYpjD1d+WLeaB/ALaEavT8YRZuSojTHCS6ozKCrHhE0QD6Ry0bg /pyQ== MIME-Version: 1.0 X-Received: by 10.224.47.2 with SMTP id l2mr7295564qaf.85.1403286385345; Fri, 20 Jun 2014 10:46:25 -0700 (PDT) Received: by 10.140.17.77 with HTTP; Fri, 20 Jun 2014 10:46:25 -0700 (PDT) In-Reply-To: <53A3874E.20704@sugarcrm.com> References: <53A1C722.9060501@fedoraproject.org> <53A21137.6010705@sugarcrm.com> <53A2A9BD.1070603@sugarcrm.com> <53A3874E.20704@sugarcrm.com> Date: Fri, 20 Jun 2014 19:46:25 +0200 Message-ID: To: Stas Malyshev , Sebastian Bergmann , Marco Pivetta Cc: Julien Pauli , Remi Collet , PHP Internals Content-Type: multipart/alternative; boundary=001a11c2acc884569a04fc48123d Subject: Re: [PHP-DEV] Re: Problems with the fix for the BC break introduced in 5.4.29 and 5.5.13 From: tyra3l@gmail.com (Ferenc Kovacs) --001a11c2acc884569a04fc48123d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Jun 20, 2014 at 2:58 AM, Stas Malyshev wrote: > Hi! > > > Wouldn't it be much easier to just revert for 5.4 and 5.5 and then > > patching `ReflectionClass#newInstanceWithoutConstructor()` to just > > handle internal PHP classes as well? > > We can not just handle internal PHP classes without calling their ctor. > That's the whole problem - for internal class, if ctor is not called, > you can get segfault on anything you do with the class. > > > Is there a technical limitation for this? > > Are there security problems related to the patch that broke > > phpunit/doctrine? If not, can the patch simply be delayed and only > > applied to 5.6? > > Right now we know this thing can produce segfaults. But running code on > unititialized data may be worse than that. > > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > I have a longer draft reply about the technical parts, but I wanted to send a quick headsup: The original SplFileObject segfault can be achived without any unserialize trick, one can simply extend an internal class depending on it's constructor for providing the required initial state, and simply not call the parent::__construct() from the child: http://3v4l.org/fqFC6 And I also think that we can't fix/remove the O:X:"Y":0:{} trick without providing some usable alternatives for phpunit/doctrine(not providing it would really hurt the adoption imo). So at the moment I see two options: 1. Revert back to the original behavior for 5.4 and 5.5, and for 5.6 introduce the original clean fix (classes implementing Serializable can only be unserialized with the "C:" format) and remove the restriction fr= om ReflectionClass::newInstanceWithoutConstructor about internal classes (a= nd make sure that we put up a warning in the docs about the potential instability of internal classes instanitated this way. 2. Do the same as suggested for 5.6 in 1) but also for 5.4 and 5.5. I think the first one is better. If we would keep the current status, it would mean for the userland project that: - for 5.6 - they should use ReflectionClass::newInstanceWithoutConstructor for non-internal classes(using clunky checks like in https://github.com/sebastianbergmann/phpunit-mock-objects/commit/4a33= 8e464a94d3e5a48ae28292e98e9b4e3ac898 ) - they should need to use the unserialize O:X:"Y":0:{} trick for internal(including non-internal classes extending internal classes) classes not implementing Serializable - they should use unserialize C:X:"Y":0:{} for internal classes implementing Serializable and because there are classes denying the unserialization or requiring specific unserialize payload (which we c= an't expect the userland to keep track of) they would have to check if the unserialize fails and throw and exception, making the instanitation of some classes outright impossible. - for 5.4 and 5.5 - they should use ReflectionClass::newInstanceWithoutConstructor for non-internal classes(using clunky checks like in https://github.com/sebastianbergmann/phpunit-mock-objects/commit/4a33= 8e464a94d3e5a48ae28292e98e9b4e3ac898 ) - they should need to use the unserialize O:X:"Y":0:{} trick for the internal classes not implementing Serializable and for non-internal classes extending internal classes implementing Serializable - they should use unserialize C:X:"Y":0:{} for internal classes implementing Serializable and because there are classes denying the unserialization or requiring specific unserialize payload (which we c= an't expect the userland to keep track of) they would have to check if the unserialize fails and throw and exception, making the instanitation of some classes outright impossible. (and both phpunit and doctrine 2 supports 5.3 where ReflectionClass::newInstanceWithoutConstructor isn't available) --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --001a11c2acc884569a04fc48123d--