This sadly does not include zend_compare() and functions relying on it because the default compare object hook (zend_std_compare_objects()) relies on zend_compare(), and adds recursion protections to OP1.
Thus making it seems difficult or even impossible for zend_compare to take const parameters.
When the JIT defers the IS_UNDEF check for FETCH_OBJ_R to the result
type guard, the deoptimization escape path dispatches to opline->handler
via the trace_escape stub. If opline->handler has been overwritten with
JIT code (e.g. a function entry trace), this creates an infinite loop.
Fix by dispatching to the original VM handler (orig_handler from the
trace extension) instead of going through the trace_escape stub. This
avoids the extra IS_UNDEF guard on every property read while correctly
handling the rare IS_UNDEF case during deoptimization.
Also set current_op_array in zend_jit_trace_exit_to_vm so that the
blacklisted exit deoptimizer can resolve orig_handler, covering the
case where side trace compilation is exhausted.
Closes GH-21368.
Reduce the number of global functions by moving it to instance method
`FileInfo::generateArgInfoCode()`.
In the process, make the following parts of `FileInfo` private:
- `$funcInfos`
- `$generateFunctionEntries`
- `$declarationPrefix`
- `$generateClassEntries`
- `$generateCEnums`
- `::getMinimumPhpVersionIdCompatibility()`
When stream_socket_server() fails during bind(), we're currently only showing
"Unknown error" in the error message. Properly propagate this error for better
diagnostics.
Closes GH-21328
* Fix ReflectionMethod::invoke() crash with internal closures
The closure identity check added in GH-21366 accessed op_array.opcodes
unconditionally, but internal closures (e.g. var_dump(...)) use
internal_function, not op_array. This caused undefined behavior when
comparing closures created via first-class callable syntax on internal
functions.
Check the function type first: compare op_array.opcodes for user
closures, compare the function pointer directly for internal closures.
* Fix internal closure comparison and expand test coverage
The previous comparison (orig_func == given_func) could never match for
internal closures since zend_get_closure_method_def() returns a pointer
to each closure's embedded copy. Compare function_name and scope instead.
Also handle the mixed user/internal type case explicitly.
Add tests for: userland first-class callables, cloned internal closures,
and cross-type (user vs internal) closure rejection.
* php_reflection: Simplify the Closure::__invoke() check
---------
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>