Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123495 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 B080F1A009C for ; Mon, 3 Jun 2024 17:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717436382; bh=5YIH+xwLkuonyK5K63KyWb5Y01/6x/AUOq6fcr/AMoU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=OY3+pfl/sVN0JsNTsbunlVsM0k2BH3UHd9ssEZTc+nI/R8sK7ybCrloiG8ggt2aQe jgg24gjY5ScquqRPtbtxSobmyPOHHJomY+RJxZKujTLUPF9MH9W1WS5CRqm9miYe5h F03a/iW8OJCwH4K/5uXqvA+ACbIh5lqctMEqbXiKoJKw2wnZ1lrz4peq1x/i2W3tri duDcSRwydJR1ITPZPhpGSQ7xDxwtT+97/jbundw41H7ODVwrVZvyAxffM1JhGN8Th4 nf6rvDLvFcROvgnIksSstRCE3CrWy2/6Yd3lpIu/Dd/tUhWuvDm6lM4NhBaivNYedV DxcJbdckogoaQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2F20A18059A for ; Mon, 3 Jun 2024 17:39:42 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS,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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Mon, 3 Jun 2024 17:39:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1717436316; bh=oUMBUPIWGn9jjFxsA09Ag/I/X4sJSfI7iYGnp66sucA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=Fu2qdD7bEuEKsyEodiz0Jk2mMYDtPe4iW5PNb2DdRBrCJTI2V2IPlJ1P5qWJBqouD qFescFxY+bqHaGvIgTCkZhAIIipFXInOKU7jE/2/UrpZFvk4CfPuXQAsNFOacyeqL2 5ZnidL2MMzC2Siik2044mFvEt8Mrj/BeLMtbOto3rNSazVu1yP0NF4k9piZNqafT6A 3G/Ff5gKkB5kniMoYANTust5ELwc6e9VPsEJT7GDSNB3lSCcK6FzyPr+/q+N3ulTVz TJ9p6uhmzEw7ZahoYSdVjaosrKAw79YlnvuzLfeXee6Kg/edgRemDfDv0CLRovCtUW wpBjmqIZoromg== Message-ID: Date: Mon, 3 Jun 2024 19:38:34 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] Transform exit() from a language construct into a standard function To: Derick Rethans Cc: Ilija Tovilo , PHP internals References: <9c69992e-2962-476d-baca-aa51bdd0f1f7@bastelstu.be> <67f2f610-dca8-e8ce-a513-2aef0fcf2698@php.net> Content-Language: en-US In-Reply-To: <67f2f610-dca8-e8ce-a513-2aef0fcf2698@php.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 5/29/24 20:05, Derick Rethans wrote: > For each op_array, Xdebug tries to figure out every possible path by > following jumps. Certain opcodes, such as GENERATOR_RETURN, THROW, > RETURN, and EXIT [1] are considered as an exit point out of the > function. A path ends there. You linked to a code_coverage.c. Is this information just used for code coverage analysis to indicate that unreachable code is unreachable and thus uncoverable or is there more to this? > If there is a function call to a function with a 'never' return type, > then that function will potentially throw, or exit. > > But that's not relevant for the analysis, as these userland functions > will have their own oparrays with their entry and exit points. > > I can't through this mechanism know when an *internal* function does > something similar, as it looks like just a normal function call (unless > I hard code the check for a call to 'exit'). The compiler has the function table available. It is used to optimize specific functions into dedicated Opcodes. Thus you should be able to look up the function within the function table and then check its return type. > [1] https://github.com/xdebug/xdebug/blob/master/src/coverage/code_coverage.c#L348 > >>> It also breaks my "do tasks on ZEND_EXIT" with the profiler. It is >>> used to always write the closing profiling footer to the files. >>> Without me being able to overload thati opcode, data would not be >>> complete. I even have two bugs (with tests) for this: >>> >>> - https://bugs.xdebug.org/68 >>> - https://bugs.xdebug.org/631 >> >> Likewise, how is ZEND_EXIT special here? How does it work differently than a >> script that runs to completion without calling exit(); or a script that fails, >> 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 > actually fully ends. This is useful for testing through phpt tests. It > looks like I might be able to use existing function observers for this, > but I haven't fully made that work yet. Why does the EXIT opcode need to be special-cased here? What if a script dies due to an uncaught Exception, due to exceeding the memory limit, or simply terminates by successfully running until the finish, without explicitly calling exit()? Best regards Tim Düsterhus