Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107491 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28262 invoked from network); 11 Oct 2019 10:35:22 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 11 Oct 2019 10:35:22 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id EEF662D203D for ; Fri, 11 Oct 2019 01:18:27 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: No Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Fri, 11 Oct 2019 01:18:27 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id w67so6397455lff.4 for ; Fri, 11 Oct 2019 01:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Cxb5Fxlhk18TCoFLXdLaIKeofBJkPn7za5O0nJ6Y5ks=; b=McTYLnFm+u4GLaoX+5ZQsmd9LbxwaPqGrsg8ehr6N+gyHNL6/6gcUB3/QrNnHUIE+S 30epzB//ZqzaFId6jR+qh1wIdJosMX0RhdC3ESIiD1Sx9/NN7Su+RP+a8WcCvcvAnFKH TVpt8FBcuSpFqtposOxnKqooL8+L144NxPYQpU2csCLjFyuc+pPx/bnjl4hmRuQ56idN YZIiy+Bdd3U3tBXGIca4V9c2V7Hqt1Z8C8IABIm1F10i26WkxrJEdur1FwAVPNgeom9P e+q2IUUNbaiRNYn1ijNvzTu2oWdenf4Y+YK6j4LZzr6OEd59fkL/miuA50k6UZtMe9Wv sK8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Cxb5Fxlhk18TCoFLXdLaIKeofBJkPn7za5O0nJ6Y5ks=; b=HEjovNnUvtJvqt7IzWC7KMmiuQ0D3LsRd+z7AhoJU0Uspzsv33DF4I/SFYk7NcL1Oi p+uHbMo9awOqQh2ar3qm0gyewU7hoCpSl9Tk1mtcHzv6cCmZDrNDnYNw+NC3K7d3U4QT wo/dUg7LLuoBP6cBJe0BErjn1D4cBUPUCHii/KLDGCsVOUg4Tq8Gkp3oKdDob1yhzIGZ i+mIxfZHSA9maM9ycTrNWau6eLaQ1ypMv4oEGrkEnED2aJtORZbsD5STqTj6/7RKTOv5 Y1RgWKHwqgi/xkKh0iWQW98h4LNBhPeeQRXBfn2iewSwLKXAOidy+h5eFlvL7Z+W3Cx0 +bCw== X-Gm-Message-State: APjAAAUgJZmyEFKYjC9jdldVqKfnOXldil0zJ5KU//ztxzBoJGg80mc0 iSAqQhGH5A4vPJoqG940W1LBymUGFy2hI2FBvORCnKTYcknIEQ== X-Google-Smtp-Source: APXvYqwa/4CQIGXWssOEoJvUnGDme4YKk4m/a9HsExo+dJH+PULUYU0FHo4iV7BnUVVlP6eDBvAQnxjK482u2tiH4v4= X-Received: by 2002:ac2:410e:: with SMTP id b14mr7980933lfi.110.1570781904942; Fri, 11 Oct 2019 01:18:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 11 Oct 2019 10:18:08 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000076bf7505949e2965" X-Envelope-From: Subject: Re: [VOTE] Reclassifying engine warnings From: nikita.ppv@gmail.com (Nikita Popov) --00000000000076bf7505949e2965 Content-Type: text/plain; charset="UTF-8" On Thu, Sep 12, 2019 at 2:17 PM Nikita Popov wrote: > Hi internals, > > I've opened the vote on //wiki.php.net/rfc/engine_warnings. > > There are 4 votes, all of them independent. The first 3 are for specific > cases that were controversial during the discussion, the last one is for > the remainder of the proposal. > > Voting closes 2019-09-26. > > Regards, > Nikita > As people have expressed interest in hearing about direct technical benefits that these kinds of changes have ... let me give you an example that came up yesterday. Opcache performs a bunch of optimizations, and one class of optimizations it does are subsequent jumps on the same operand. For example: if ($x) { A; } if ($x) { B; } Currently, opcache will optimize the first if($x) condition to jump directly until after the second if($x) if the value is false, on the expectation that it is redundant to check the same condition twice in a row: The result is going to be the same. Basically the result is something like this: if ($x) { A; } else { goto end; } if ($x) { B; } end: Now, it turns out that this entire class of optimizations is technically illegal. Why? Because $x might be an undefined variable! That means that this optimization at the least loses an "undefined variable" notice, and at worse changes control flow: set_error_handler(function() { $GLOBALS['x'] = true; }); if ($x) echo "foo\n"; if ($x) echo "bar\n"; Because it's been around for years and doesn't seem to have caused any active issues, we're likely going to keep this, but nonetheless, it illustrates the kind of issue we see with these notices. Either an exception or nothing at all are fine, but notices caused problems. Of course there are also other problems, such as https://bugs.php.net/bug.php?id=78598, which is one of multiple use-after-free issues related to notices thrown during write operations. The root cause is that under the PHP memory model, it is not legal to run arbitrary user code while holding writable references into structures -- an invariant that is violated by some notices, such as the undefined array key one, because those notices may invoke error handlers. Again, either throwing nothing or throwing an exception would be unproblematic. Generally notices thrown by the engine are a pretty big pain to deal with, as well as something of a correctness and safety hazard. We have quite a few bugs in this area, though most of them are thankfully not likely to be hit by accident. Nikita --00000000000076bf7505949e2965--