Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113231 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92624 invoked from network); 23 Feb 2021 16:24:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Feb 2021 16:24:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3D20F180505 for ; Tue, 23 Feb 2021 08:12:54 -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-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 08:12:53 -0800 (PST) Received: by mail-lf1-f42.google.com with SMTP id v30so12031315lfq.6 for ; Tue, 23 Feb 2021 08:12:53 -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=1uGrHoATQh6AdXDwgKqTx2W68jbB2jBTaWPoNYr99Rk=; b=tVEI1cWBXNDMMwrc/1Jqxmy6Wv1D5QHc01CZUlIXosS0lCQE+HO+BF/ZYCp/RbGaSs dKUStqVoJj30CxTk2xkqr52d2gIUFNnFDGWdWB0q0rSmH5Z8g1D06ruwiqv4kb/YOUzQ zxOSElxUAw+sjkK5ezj0mz22a/Q1zPaOhku9ZjgUqq0pl38F2zNw7YT1ga8UAc5dQ+Gn rJzcWqEhiEojYyqL/iaZUvQR1eHS3EAeeQRnwWX72SpN5RkoCMIIuUDaEHv5lZbrdQZg JyVqF5xQ8z5hDlNEB6v5KIqhcJO16kYDBKERR/6McfUyIZH4Pdz5R2nB+kp+tWSNAX/h QH5Q== 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=1uGrHoATQh6AdXDwgKqTx2W68jbB2jBTaWPoNYr99Rk=; b=B55RHrCaJyjbcI61pn7vwxjuYrLN0aIfHa1Dn+7g6qU7LvBBEWxzlZVq06ucuGjaPv UWgJBgJrA67NYq5D3ZqQzc9c6jYM0T3QvykyQ2ItMwMTX4pmnH3xpz2GhH+VHG3vY+YM wKnZnnk9vOsmYSNFph6qS5VcFrvictHWt6om1F8DAFM5T05irliVGcBphGW2Zh12FM5j 7uKdDA1yO1YSmtFO2HA/zHKYgceT8xSHNTEWp3EX7z4o5nWqfSNUzQ1yG7MeDSGFyuyH d7hp9jgzzfQDxzZftI3UEyzIO3L9alqOLRBMaddZm4Aovn2sy43Lv1GuGtlWFIqImKtF GLXA== X-Gm-Message-State: AOAM5300O8XwkMKdepXHw1D6zgCeyt4MaKdYPq5ZzsPZH3xiyVC8PgKP ZApkZdLCOBhsTWmKqXiAenD0q9CsAYLi3u4m1Z8= X-Google-Smtp-Source: ABdhPJx2VTdt+KRH4yFvpO8kGbMVJmIQvtYAsmsPqK6/7XKH5u4ureft7o0+/ThFW/3uO3lRATw26fQbML/nNfOCIWQ= X-Received: by 2002:a05:6512:3090:: with SMTP id z16mr17608281lfd.44.1614096767558; Tue, 23 Feb 2021 08:12:47 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 23 Feb 2021 17:12:30 +0100 Message-ID: To: Guilliam Xavier Cc: "G. P. B." , PHP internals Content-Type: multipart/alternative; boundary="00000000000076a8ae05bc03306c" Subject: Re: [PHP-DEV] Interaction between finally blocks and exit() From: nikita.ppv@gmail.com (Nikita Popov) --00000000000076a8ae05bc03306c Content-Type: text/plain; charset="UTF-8" On Tue, Feb 23, 2021 at 4:52 PM Guilliam Xavier wrote: > 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? > Finally blocks are intended to be always executed when destructors are executed. The fact that they are not yet executed for exit() outside generators is a known bug. (For generators, finally is part of the destructor, which is why the issue does not appear there.) Regards, Nikita --00000000000076a8ae05bc03306c--