Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70544 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1256 invoked from network); 9 Dec 2013 07:39:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Dec 2013 07:39:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 209.85.212.175 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.212.175 mail-wi0-f175.google.com Received: from [209.85.212.175] ([209.85.212.175:61771] helo=mail-wi0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/C1-23208-C9375A25 for ; Mon, 09 Dec 2013 02:39:09 -0500 Received: by mail-wi0-f175.google.com with SMTP id hi5so3325489wib.2 for ; Sun, 08 Dec 2013 23:39:06 -0800 (PST) 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=btF9T8Gofkw41PoP+nxLIT8MCzpYZjgCTKs1fJpkSn0=; b=RfiQS2BTtv0eE0B+6OHjhPotnMUcrL2X7X9NKiW8H2IJn+RrnOgwOCYAYfwOfUb+y1 B1aV4ZaPzyWGLHj90AuhxFGEJGWeW6eIDGE2wpXGZSOg+uK98Ef1lYenveR2e2qGVLaP 5/Ow9LOTYZWvOqeAV/CL/Kb0n3fmbFHUua64GAU+3ZDSSw4dyKBnkfkfUen5qGqsjZPa K4WxE5S9lIpjomMt13vNGpn9rbwOGpW1Ip22buTrspqS+qjHSOz2CpKAVaERbmpFl+mS NPT6/3w1OwaKzuBn0ln+12tHg/iDtX6zeS2X7nJsgtRqyYcMQ30mbwZnR1r4V4ox3HUw fbnw== X-Gm-Message-State: ALoCoQnV/4/38WEAzbVXH/QWt6uVPBy8/9RGE8GYBeXs5SCRlZI6sT6rNdW+oHP9BmzU6GlK8d3yePTKAZE8aa8DBqRCcPQwrfNUgVZp7bsJuzVpUdarGQgyMQfmf1YxJZo12cHQEcYm MIME-Version: 1.0 X-Received: by 10.180.85.71 with SMTP id f7mr6678719wiz.41.1386574746049; Sun, 08 Dec 2013 23:39:06 -0800 (PST) Received: by 10.227.91.198 with HTTP; Sun, 8 Dec 2013 23:39:05 -0800 (PST) In-Reply-To: <52A0B513.2010108@gmail.com> References: <528CE64A.1020303@gmail.com> <52A0B513.2010108@gmail.com> Date: Mon, 9 Dec 2013 11:39:05 +0400 Message-ID: To: Terry Ellison Cc: PHP Internals Content-Type: multipart/alternative; boundary=f46d044280b431725104ed15176e Subject: Re: Comments on non-unique naming convention for closures From: dmitry@zend.com (Dmitry Stogov) --f46d044280b431725104ed15176e Content-Type: text/plain; charset=UTF-8 hi Terry, Please share the new PHPT tests or better attach them to bug report. (D) looks reasonable simple. I thinks it must be a good enough solution. For ZTS we can use thread_id in addition to PID (or instead of it). Also we may use a simple thread specific counter instead of microtime - CG(key_counter). Thanks. Dmitry. On Thu, Dec 5, 2013 at 9:17 PM, Terry Ellison wrote: > Dmitry, > > The underlying issue here is the assumption that > build_runtime_defined_function_key() in zend_compile.c generates unique > keys. I've realised that this impacts not only closures but also > late-bound functions and classes. I've now produced PHPTs which > demonstrates the failure in all three cases. Whilst hashing a closure > source text has an acceptable compile-time overhead, the case for classes > (with their larger source lengths) is more of a concern. > > I am now proposing an alternative hash based on: > > A. The class / function name (as per current) > B. The reference source file (as per current) > C. The address of the buffer (as per current) > D. The PID and microtime at the request start. > E. A running count of the function/classed compiled during the request. > > (A-C) were assumed unique but, as #64291 and #65915 show, are not. > > (D) should be sufficient to prevent race conditions across different > OPcached threads / processes, but this has the advantage that it only needs > to be computed once per request. > > (E) guarantees uniqueness within thread. > > The only weakness of D and E alone is a possible race on ZTS builds where > two clashing threads start at the same microsecond, which (C) will split. > If this is considered too unwieldy then we could always drop B as C-E > guarantee uniqueness, and B is never exposed to the programmer anyway > (Xdebug and the error logger use the appropriate fields in the > zend_function / zend_class record and not its key in the corresponding EG > table. > > This also has the advantage that the main change can now be localised to > build_runtime_defined_function_key(). > > //Terry > > The following bugs relate to this discussion: > > #64291 Indeterminate GC of evaled lambda function resources > #65915 Inconsistent results with require return value > > I don't want to discuss these or the specific fixes here, since I can work > up a fix and discuss them in the bugrep. However, > my one-sentence Q is "should we replace the naming convention for closures > with a truly unique one?" ... > > > --f46d044280b431725104ed15176e--