Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113230 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90455 invoked from network); 23 Feb 2021 16:03:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Feb 2021 16:03:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 578961804D1 for ; Tue, 23 Feb 2021 07:52:22 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 23 Feb 2021 07:52:21 -0800 (PST) Received: by mail-lf1-f43.google.com with SMTP id m22so11929237lfg.5 for ; Tue, 23 Feb 2021 07:52:21 -0800 (PST) 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 :cc; bh=+DOQrVv7vY9cNFlffbFbb/ETAumq0ADS/7IqtNUVEkQ=; b=paT6uRxba1wbFvexDdX6wxCZ8IHbwOXICtQ1pL3HTYOICOlEYbLPn03a3k78Ws+qGq 0aofgFMihpHvwoYRvb+hhHLsa0xObNDl0PRSEgHKDDidUxX8lKonq19k2HKA0mcsnzM0 JgVtGD1IjT3UjDLI93ypty8s1WvpqX9XmMqTesigRbK1j1qrDIvaH/L3zy7VtAMYoMMy XpekNH5pg10CjPkZnVck3H4XO2nbUp3jRFTUqVZgp+BthPQm3ZAPbvJ7EfBvjXj5kMmZ Pm0SzQPAnj7lN/b+6ksOaNrR22M/IX7pev+6j/X0ayFg11IDo4gRPHg6Yz7WZ+aOHARD ZuUA== 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:cc; bh=+DOQrVv7vY9cNFlffbFbb/ETAumq0ADS/7IqtNUVEkQ=; b=sACRjV3J06OneMtNVL7x46v4yGlWI9C8+Af8QG9QgDhmmlrkmFZ9T7v8pyLhEh7OhK jfHIB82Ikt6E60X5nO8DD2Hukj9g7I9DWhOXI0T33YdetNdi43XecmKMXjo6MOHdAvS8 h7EQIUhYvkH3D77VjHl6pZrqdGlP09rE/K5YYKPhDNqZ8767ayOxDw9mtlVgEtoLQ3B6 oGrYuUKBcscFbXSnGsxTuloLQiEm9yu2n5t8Qa2zyIAbl9mSNU8cgTRevj4wxXWxaayf +DlcDPcVRcSX2h4u4uf3MP7aD0RX2K/ajLTNrQzq415hni36SYJiKNPQW9UW+egr8eW1 COJg== X-Gm-Message-State: AOAM531Q9ImNni+rD+lSqPvqnmKi3xILA4puyCwaw54um2aKQE7JgpxJ dIdtqUSIs8HmwxH6ilyP2imhZd3BoXyrKjUepw== X-Google-Smtp-Source: ABdhPJzJtq+Y+dOq1lJ8sFap03ZuCVLEio95czBzG4HKjI2EMFfdogLJu9Qsux2kQtSxrHgexs21Kw7cgwI8HD3WG/4= X-Received: by 2002:a05:6512:1156:: with SMTP id m22mr16617495lfg.637.1614095539820; Tue, 23 Feb 2021 07:52:19 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 23 Feb 2021 16:52:10 +0100 Message-ID: To: "G. P. B." Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000048f5be05bc02e722" Subject: Re: [PHP-DEV] Interaction between finally blocks and exit() From: guilliam.xavier@gmail.com (Guilliam Xavier) --00000000000048f5be05bc02e722 Content-Type: text/plain; charset="UTF-8" On Fri, Feb 5, 2021 at 2:10 PM G. P. B. wrote: > Greetings internals, > > While working on rewriting the PHP docs about errors and error handling [1] > I came across a change of behaviour in an edge case of an edge case. > > finally blocks are meant to be always executed regardless that an Exception > has been thrown or not, which it does, however a call to exit() (or die() > as they are aliases). > This can be seen with the following example: https://3v4l.org/6Tger > > However, there is one case where finally blocks are executed when exit() is > used, namely when a generator has a finally block and exit() is called > during its traversal, an example of this in action can be seen here: > https://3v4l.org/HGKHS > > The behaviour of this edge case of an edge case is highly dependent on the > version of PHP where this is run, PHP 5.5, 5.6, 7.0, early version of PHP > 7.1, PHP 7.2.0, PHP 7.2.1, and PHP 8.0 all run the finally block on exit(). > Later versions of PHP 7.1, 7.2.2 and above and PHP 7.3 and 7.4 all skip the > finally block. > > Frankly this is already going to be a mess to document, but this begs the > question is there a "bug" in executing the finally blocks in generators > during a call to exit() or is the "bug" to not execute finally blocks when > exit() is called. > > I've CCed the PHP 8.0 RMs as if the consensus is that skipping finally > blocks after a call to exit() is performed it would be wise to change this > behaviour in PHP 8.0 only and land this ASAP, even though it's a BC break. > > Interested in hearing your thoughts. > > Best regards, > > George P. Banyard > > [1] https://github.com/php/doc-en/pull/320 > Hello again, From my message from two weeks ago, my understanding is that finally blocks are *never* supposed to be executed on exit(), and that there is indeed a bug (regression) with generators. With PHP 8.0.3RC1 having been released without any reply here from the people CCed, maybe you should open a bug report? -- Guilliam Xavier --00000000000048f5be05bc02e722--