Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124785 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 70A0C1A00B7 for ; Mon, 5 Aug 2024 19:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722884684; bh=tF7anFT6kiZN/40GlWERGsib46ShaplbjLlLMUZ/6bM=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=Jw1l5aJ2PeSYNnAkdQR7jGnVpS65DqmfCw9dy65/e4z1TX6yW+VN2vssG908Jy9S5 nqMp8Wn3dFbzawCRpVxQIMRXAFXIUB+33QnCoW+ztuI4vhczsZLYv5mcbrlvEA5cqc iboonsyHi0zOlaWO9MCRCL8fiFn+hqRmQ7ffDhInhGHB0IitcwMjvYPNRAju4q8rbY YGbHR/ktoKIXNNrJz0aEi5QwMceOzUsTad9yCGhnjNLbpKumrBTQZxcMgAkc9zmKi9 GbcjafeqQZw6lJJVGo1PqZNjX0pgJ0I0sKzr3IYU6TM+RPIFaVYuQVJAPLQbXrggrC ymiPS5Rj7Gbig== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4318A180072 for ; Mon, 5 Aug 2024 19:04:43 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) (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, 5 Aug 2024 19:04:42 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 621EB1148445; Mon, 5 Aug 2024 15:03:01 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute3.internal (MEProxy); Mon, 05 Aug 2024 15:03:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1722884581; x= 1722970981; bh=tF7anFT6kiZN/40GlWERGsib46ShaplbjLlLMUZ/6bM=; b=F QCWrCMX7PxLxScz++2cUAxoTbVl2N0i2bKHJ3OGMaiZiVejSU3Pm8c1S3R5iCjLr 5f6E5KIEkm4fRUdFDqijzgOvhlOYUJBSggOoqz8ruIFz3xJQ1qiJLR6ViOzmEaXz HimEE0H7GVFKDF3BWCMV5JgWzlAZKNgfF5qyT/Ben/rZPDLSTcWXCY8oTrcFZ3i1 ec+Op437pYK194YehfRf9yfMV6MMrGj2YMk48fJYroXUkutqILgexNlZWpo56FOU 9oyODzuermgZY21Wei/e5YbPpuE9Gzc+r2ncWMLe2XnYbAI5zQz7sUAocOSZ7rIp flonWDJEypEB5Q79Zt0NA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722884581; x=1722970981; bh=tF7anFT6kiZN/40GlWERGsib46Sh aplbjLlLMUZ/6bM=; b=rgrNr5oANBs73wbn3keqyDltEUxtbySk1MB+IA+dZ9C3 /Hj0oGn2PpPJJ7aEuFOju87Op1zXua3KPMJ76OqPr1PM+/rZB1Hta/HjMZr7hqjl jqKTMw8Xvn93fjGXoNcnlyi2s2yBzWOIJPgIjuZ7xo5WC16qbGmhlq1TMbgO6mmh wekS1ZBbm5ZGlyHi3d7iNZpuqlGVhuwtd49tumMBe7Opk5jkYdz7PIdm73Pjkxfk D+rS6TEdaV8f5czqvb2iLKZB1xOY8IbTlCdkSmt2nIsFwY6kemRx8KsQnXAI53sf 5ZypWSD+06Ggr51PjYa1nF5KufhDl9ITubycaNOtLQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrkeeigddufeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhushhpvggtthffohhmrghinhculdegledmnecujfgurhepofggfffhvfevkfgjfhfu tgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgsse gsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpefhveetveeuhfejiedt hefhveegvddvgfdujeevudekfffhhedvgfffgedvleefffenucffohhmrghinhepfehvge hlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mheprhhosgessghothhtlhgvugdrtghouggvshdpnhgspghrtghpthhtoheptd X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 163EE15A0092; Mon, 5 Aug 2024 15:03:01 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Mon, 05 Aug 2024 21:02:39 +0200 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , "Derick Rethans" Cc: "Ilija Tovilo" , "PHP internals" Message-ID: In-Reply-To: <5943ce1d-fd0d-4efa-be7e-a2df456253b1@bastelstu.be> References: <9c69992e-2962-476d-baca-aa51bdd0f1f7@bastelstu.be> <67f2f610-dca8-e8ce-a513-2aef0fcf2698@php.net> <9492f9e2-7390-de77-b524-cd84ff452157@php.net> <5943ce1d-fd0d-4efa-be7e-a2df456253b1@bastelstu.be> Subject: Re: [PHP-DEV] [RFC] Transform exit() from a language construct into a standard function Content-Type: multipart/alternative; boundary=62bcb16e02e84f148509d4eea7a9271f From: rob@bottled.codes ("Rob Landers") --62bcb16e02e84f148509d4eea7a9271f Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Aug 5, 2024, at 19:03, Tim D=C3=BCsterhus wrote: > >>> 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. > >> > >> The compiler has the function table available. It is used to optimi= ze > >> 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. > >=20 > > Yes, but functions that call exit are not required to have the 'neve= r' > > return type, so that's not useful. >=20 > The `exit()` function as implemented in Gina's PR has the `never` retu= rn=20 > type, thus the situation is no worse than the current situation. Inste= ad=20 > of checking for the ZEND_EXIT opcode, you check for a function call an= d=20 > if the function has the `never` return type (which `exit()` is=20 > guaranteed to have), then you can treat it as a path ending there. Or=20 > you can just hardcode a check for a call to the `exit()` function, as=20 > outlined above. Just to clarify: a never return type doesn't mean execution ends there. throwing: https://3v4l.org/s3KDM infinite loop: https://3v4l.org/Lpbtt =E2=80=94 Rob --62bcb16e02e84f148509d4eea7a9271f Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Mon, Aug 5, 2024, at 19:03, Tim D=C3=BCsterhus wrote:<= br>
>>>= ; 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
>>&= gt; functions will have their own oparrays with their entry and exit
=
>>> points.
>>
>= ;> The compiler has the function table available. It is used to optim= ize
>> specific functions into dedicated Opcodes. Th= us you should be able to
>> look up the function wit= hin the function table and then check its
>> return = type.

> Yes, but functions tha= t call exit are not required to have the 'never'
> retu= rn type, so that's not useful.

The `exit()`= function as implemented in Gina's PR has the `never` return 
type, thus the situation is no worse than the current situation= . Instead 
of checking for the ZEND_EXIT opcode, you = check for a function call and 
if the function has th= e `never` return type (which `exit()` is 
guaranteed = to have), then you can treat it as a path ending there. Or 
you can just hardcode a check for a call to the `exit()` function= , as 
outlined above.

=
Just to clarify: a never return type doesn't mean execution e= nds there.

throwing:

infinite loop:

=E2= =80=94 Rob
--62bcb16e02e84f148509d4eea7a9271f--