Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123455 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 1CB541A009C for ; Wed, 29 May 2024 18:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717006021; bh=ZNGvJOpTCD9llrMOdEhHTiKzLNNRqwKQxGw77aF2hLQ=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=W42R4qKIdCZazBrhTQrZWipykCpDSfkFR3vv1FQLUUGTplWcRrEumkXGzbQy7HRTW P1mk8NcNR1NHnqRdPZ5tNS346kwBFJ2Fl3sEaAZI1m1NJNBYpiL3igZeqovdiVyhNC t6t6nqaiqdDgk++lGmZ0sRwOElHAtYV0xVKoPPVv6Stj/0SeXHQxb7CarMLPRnZxvZ 642f5N/O2Ao1KnfExNfRoYgmgIa3GqhmobTKRk5g9rw7dv1D/JcV+XdqRB8Mq+QTAx D5yOrP71rLT70m2Do8w82rSxJweFf2pv7/57NZb9OZV/cq57GeAfrrfBZPK9UtxW+i m6BWEkzaufIkQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 280DB180056 for ; Wed, 29 May 2024 18:07:00 +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,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) 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 ; Wed, 29 May 2024 18:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717005957; bh=ZNGvJOpTCD9llrMOdEhHTiKzLNNRqwKQxGw77aF2hLQ=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=URGhs1BOSs1+jr6BaV2Fz0WhguCn8kP7Npy6A/4HJsLpgyniSXz2RFAmzNzmCeCkx nipFaSpl3dt1K1nz4UwAO7VuK/O9XL3Tk5oJmbToBGnnheCVJP+OqLGi/ffFHGggrU y4vqwBMzB+HjNdTt4aOfbXT6IGtEfdbdSYJ/+6ayQP3YdfYFwbdRR9tWnDPyq4aTod 1HfxX2Ke3JshlzCQimFcYngmCeh/6j9/T3CKvmVDnrhd6oGBSUQ/AIwB51xs9vz+z2 oxODnyBqf1hWm/YJQpczDFwvopxXHRjmE5xuF+m7F6czTuQWpP9TzOfNzKq/lSmXv3 h3PEJVzo22jew== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id B666D10C539; Wed, 29 May 2024 19:05:57 +0100 (BST) Date: Wed, 29 May 2024 19:05:57 +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: <9c69992e-2962-476d-baca-aa51bdd0f1f7@bastelstu.be> Message-ID: <67f2f610-dca8-e8ce-a513-2aef0fcf2698@php.net> References: <9c69992e-2962-476d-baca-aa51bdd0f1f7@bastelstu.be> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-295662134-1717005957=:61845" 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-295662134-1717005957=:61845 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 28 May 2024, Tim D=C3=BCsterhus wrote: > On 5/28/24 16:26, Derick Rethans wrote: > > > I have just checked this for Xdebug, and you're definitely right=20 > > with that. With the removal of the ZEND_EXIT opcode, it can not now=20 > > detect a scope/function exit now. >=20 > Can you clarify why ZEND_EXIT is special for Xdebug when compared to=20 > any other function that unconditionally throws or unconditionally=20 > calls exit(); by itself, i.e. any other function with a `never` return=20 > type? 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. If there is a function call to a function with a 'never' return type,=20 then that function will potentially throw, or exit. But that's not relevant for the analysis, as these userland functions=20 will have their own oparrays with their entry and exit points. I can't through this mechanism know when an *internal* function does=20 something similar, as it looks like just a normal function call (unless=20 I hard code the check for a call to 'exit'). [1] https://github.com/xdebug/xdebug/blob/master/src/coverage/code_coverage= =2Ec#L348 > > It also breaks my "do tasks on ZEND_EXIT" with the profiler. It is=20 > > used to always write the closing profiling footer to the files.=20 > > Without me being able to overload thati opcode, data would not be=20 > > complete. I even have two bugs (with tests) for this: > >=20 > > - https://bugs.xdebug.org/68 > > - https://bugs.xdebug.org/631 >=20 > Likewise, how is ZEND_EXIT special here? How does it work differently tha= n a > script that runs to completion without calling exit(); or a script that f= ails, > e.g. due to an uncaught exception or due to reaching the memory limit? I overload EXIT so that I can flush the profile file before the script=20 actually fully ends. This is useful for testing through phpt tests. It=20 looks like I might be able to use existing function observers for this,=20 but I haven't fully made that work yet. cheers, Derick --=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-295662134-1717005957=:61845--