Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75151 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40323 invoked from network); 30 Jun 2014 19:32:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jun 2014 19:32:17 -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.220.179 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.179 mail-vc0-f179.google.com Received: from [209.85.220.179] ([209.85.220.179:55259] helo=mail-vc0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/53-19922-04BB1B35 for ; Mon, 30 Jun 2014 15:32:17 -0400 Received: by mail-vc0-f179.google.com with SMTP id id10so8090028vcb.10 for ; Mon, 30 Jun 2014 12:32:14 -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:content-type; bh=N0gnq0K4cZ0c16uvLy9UnbJEz1X4Ys/LSfpLnyBDfSI=; b=MPUDwFGgh+V1EQYsyz3Thl6ZV5SBSQAyhV05FfsWkc8obcDqBCotti03B5M/wAbVUg Zy0IH2znj23wZL8DMPBEhA7/4eH1MaVFe1DmTkssTq9UNwlCpALbGOf/TV+7YpZTYlQt 05l1XCH3q1+fUXOyN2WoTF+V0DmUZi7+VVJBepHDZ/8yfXoIyLksgZB7SlZ6/ebaq//P HCwqqHv37wf7isbg3K2jvyFNESHUfoMGwfycHGg5CvAQbIHPT8j4zGUFfC0gjn0xs07H JuvN8YuNvp0QiTv42wwiwrHROs8TZy4LJIAoyuSV6xsfzfCZZ3kNcnDlj7JbSfWneyEr sFQg== X-Gm-Message-State: ALoCoQkYCS2uXiccMRl6uzCu1fk9X/bGhXdtc2WVZPnsVs9yrDWM8SUnUSeoKuNqs6skUMq7nMGA35ngqVwaaR9WSqlWTrwVFlL/fRTJDZatvB+qNZGlCLVIkIkQyGnS1KlS9mr4pGWt MIME-Version: 1.0 X-Received: by 10.220.44.141 with SMTP id a13mr170259vcf.71.1404156734118; Mon, 30 Jun 2014 12:32:14 -0700 (PDT) Received: by 10.52.111.71 with HTTP; Mon, 30 Jun 2014 12:32:14 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 Jun 2014 23:32:14 +0400 Message-ID: To: Bob Weinand , PHP Internals Content-Type: multipart/alternative; boundary=047d7b34309458b23904fd12b798 Subject: Re: [PHP-DEV] Wired constant expression syntax and bug From: dmitry@zend.com (Dmitry Stogov) --047d7b34309458b23904fd12b798 Content-Type: text/plain; charset=UTF-8 OK. I'll commit the patch. According to the wired syntax, note that your example code will make PHP at first construct an array and then destroy it. why not to write $var = DO ? "value1" : "value2"; it must be more clear and efficient. In case you like to keep this new syntax in PHP-5.6 at least please cover it with tests. I'm not a big fun of it, but won't object if it can't make real harm. Thanks. Dmitry. On Mon, Jun 30, 2014 at 11:21 PM, Bob Weinand wrote: > That syntax wasn't part of the RFC because it wasn't yet possible > (existence of IS_CONSTANT_ARRAY at that time). > Also the use case for that one is mainly: > > class Foo { > public $var = ["value1", "value2"][DO]; > } > > And then just write > const DO = 0; (or 1) > > I don't exactly know at which point that conflicts with opcache. Or if > that really fixes the bug. > The copying itself in your patch looks fine, but please take the > responsibility for it and apply it yourself. > > Thanks, > Bob > > Am 30.6.2014 um 21:06 schrieb Dmitry Stogov : > > Hi Bob, > > > > I'm wondered why you introduced this wired syntax in PHP-5.6. > > > > class FooBar { > > const bar = ["bar" => 3]["bar"]; > > } > > > > It wasn't a part of RFC, it wasn't covered by tests, and it actually > > doesn't make a lot of sense. May be it's better to remove it? > > > > Also I found a constant expression related bug, that leads to > unpredictable > > crashes from time to time. Previously we had IS_CONSTANT_ARRAY that was > > handled in a special way. When you replaced it with IS_ARRAY, you missed > > this handling, and I missed it as well when reviewed your patch. Now > > IS_ARRAY constants might be incompletely copied from OPCache shared > memory > > and modified (incremented/decremented reference counter) directly in SHM. > > Such modifications occur in simultaneously running processes and this > > finally leads to crash on some race condition. > > > > It's possible to emulate the problem running the following script with > > opcache.protect_memory=1 > > > > > function foo($query = NULL, array $exclude = array('q')) {} > > foo(); > > ?> > > > > I propose a simple fix: > https://gist.github.com/dstogov/b73884e252b376957ebc > > Please review and apply if agree. > > > > Thanks. Dmitry. > --047d7b34309458b23904fd12b798--