Re: [RFC] Transform exit() from a language construct into a standard function
| From: | Rob Landers | Date: | Mon, 05 Aug 2024 19:02:39 +0000 |
| Subject: | Re: [RFC] Transform exit() from a language construct into a standard function | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-124785@lists.php.net to get a copy of this message | ||
On Mon, Aug 5, 2024, at 19:03, Tim Düsterhus 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 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.
> >
> > Yes, but functions that call exit are not required to have the 'never'
> > return 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 the 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 ends there.
throwing:
https://3v4l.org/s3KDM
infinite loop:
https://3v4l.org/Lpbtt
— Rob