Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124715 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id CA4421A00B7 for ; Fri, 2 Aug 2024 11:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722598862; bh=38Ds0LBuIHviRwZ/Ni1JXCusny0CmbMAER22h6y8YUM=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=e3tV1p94rgOQD/0zIJf7zmYYGjcIgKWKqyIN4569bv/glNnMe5rq0Dvl4jDKdzVJa LMnY0xxQsPLA4DYKw3hOniFVHsATLRnQ8GhG11AysTW94i4hA64OEi5BL5fm4g8gRC 71Jepab66WZsJ4w/HBSmm9Qj0a+noYt3i9bNaQywFWC4PYtWquKfR2LbTLDcLmXVeY W/Eg/lz88GDa9nwFG0Ta+SMywBdnH9TBOjCOOW0zFCg/6rqfDg0v3EWzVueeU+Wxbk klGrra4T1CdVq7RT/Y8c1ae1Mh8sOtQyPpbhTiuzdhv1Ki2/U50oso3S+PrnELmn8a xovrNb8VEtQGg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ED030180077 for ; Fri, 2 Aug 2024 11:41:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: *** X-Spam-Status: No, score=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 2 Aug 2024 11:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722598760; bh=38Ds0LBuIHviRwZ/Ni1JXCusny0CmbMAER22h6y8YUM=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=Nhq84Fy+6uVe7dLWZ4AqOvNBAdVcnO8u2alQZ1ngsQHVcdypenPNxc4NG3EiicS2+ 3t2oeD0SNjcI/UcaELBzsWwBlMJv2wkTgBSe0iaxbzRqtZdvKd4RqYvhvHPfpJTzNs UigeTUuY5Bmte/TEgs6kGMTltiRHRUhLkCkwXv43FO8Edy8sU8Y9DDjpJwRJTBTgye LYT1/tLvhlvGdpm4sww3bOcVuJUcau3Tt83LciBNgr4CiN5zYhor5z/sNpLMy16S39 Wn+qpSV6IpI3S/CKJ382HIgPfBnrLgVAzNADpPhl15XZBpOJ3Br4/9OJ6djFufYxhy gSwpLqhAcqmgQ== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 9BF6610C0B0; Fri, 02 Aug 2024 12:39:20 +0100 (BST) Date: Fri, 2 Aug 2024 12:39:20 +0100 (BST) To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= cc: Ilija Tovilo , PHP internals Subject: Re: [PHP-DEV] [RFC] Transform exit() from a language construct into a standard function In-Reply-To: Message-ID: <9492f9e2-7390-de77-b524-cd84ff452157@php.net> References: <9c69992e-2962-476d-baca-aa51bdd0f1f7@bastelstu.be> <67f2f610-dca8-e8ce-a513-2aef0fcf2698@php.net> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-843412422-1722598760=:23442" From: derick@php.net (Derick Rethans) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-843412422-1722598760=:23442 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 3 Jun 2024, Tim D=C3=BCsterhus wrote: > On 5/29/24 20:05, Derick Rethans wrote: > > > > For each op_array, Xdebug tries to figure out every possible path by=20 > > following jumps. Certain opcodes, such as GENERATOR_RETURN, THROW,=20 > > RETURN, and EXIT [1] are considered as an exit point out of the=20 > > function. A path ends there. >=20 > You linked to a code_coverage.c. Is this information just used for=20 > code coverage analysis to indicate that unreachable code is=20 > unreachable and thus uncoverable or is there more to this? It's for that, but also for path/branch analysis, as I just wrote above. Having an EXIT opcode, instead of a function call is a clean indicator=20 that a path (and branch) ends here. With a function call, I have no idea about whether a path ends there. > > If there is a function call to a function with a 'never' return=20 > > type, then that function will potentially throw, or exit. > >=20 > > But that's not relevant for the analysis, as these userland=20 > > functions will have their own oparrays with their entry and exit=20 > > points. >=20 > The compiler has the function table available. It is used to optimize=20 > specific functions into dedicated Opcodes. Thus you should be able to=20 > look up the function within the function table and then check its=20 > return type. Yes, but functions that call exit are not required to have the 'never'=20 return type, so that's not useful. > > > > It also breaks my "do tasks on ZEND_EXIT" with the profiler. It=20 > > > > is used to always write the closing profiling footer to the=20 > > > > files. Without me being able to overload thati opcode, data=20 > > > > would not be complete. I even have two bugs (with tests) for=20 > > > > this: > > > >=20 > > > > - https://bugs.xdebug.org/68 - https://bugs.xdebug.org/631 > > >=20 > > > Likewise, how is ZEND_EXIT special here? How does it work=20 > > > differently than a script that runs to completion without calling=20 > > > exit(); or a script that fails, e.g. due to an uncaught exception=20 > > > or due to reaching the memory limit? > >=20 > > I overload EXIT so that I can flush the profile file before the=20 > > script actually fully ends. This is useful for testing through phpt=20 > > tests. It looks like I might be able to use existing function=20 > > observers for this, but I haven't fully made that work yet. >=20 > Why does the EXIT opcode need to be special-cased here? What if a=20 > script dies due to an uncaught Exception, due to exceeding the memory=20 > limit, or simply terminates by successfully running until the finish,=20 > without explicitly calling exit()? It's not important for normal functionality as the execution still ends=20 there. It's useful for *testing* as I said before. >=20 > Best regards > Tim D=C3=BCsterhus >=20 --=20 https://derickrethans.nl | https://xdebug.org | https://dram.io Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/suppo= rt mastodon: @derickr@phpc.social @xdebug@phpc.social --8323329-843412422-1722598760=:23442--