1
0
mirror of https://github.com/php/php-src.git synced 2026-03-29 19:52:20 +02:00
Commit Graph

6251 Commits

Author SHA1 Message Date
Niels Dossche
38e1b0ac8c Fix GH-16572: Incorrect result with reflection in low-trigger JIT
When a recursive call happens with invalid arguments, the maximum valid
arguments are computed and stored in `num_args`, but the RECV entry
block we jump to is `call_num_args` instead. This can skip argument
validation checks. Fix this by using `num_args` instead.

Closes GH-16575.
2024-10-28 19:31:52 +01:00
Niels Dossche
757781a142 Fix GH-16577: EG(strtod_state).freelist leaks with opcache.preload
This happens because on ZTS we execute `executor_globals_ctor` which reset the
`freelist` and `p5s` pointers, while on NTS we don't.
On NTS we can reuse the caches but on ZTS we can't, the easiest fix is
to call `zend_shutdown_strtod` when preloading is shut down.
This regressed in GH-13974 and therefore only exists in PHP 8.4 and
higher.

Closes GH-16602.
2024-10-28 19:30:52 +01:00
Ilija Tovilo
cd8ee4dad1 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix lineno in function redeclaration error
2024-10-22 15:06:06 +02:00
Ilija Tovilo
381e020edb Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix lineno in function redeclaration error
2024-10-22 15:05:29 +02:00
Ilija Tovilo
de7ef3fa66 Fix lineno in function redeclaration error
We were previously using the lineno of the first instruction, rather than the
start of the function itself.

Fixes GH-16509
Closes GH-16531
2024-10-22 15:04:20 +02:00
Dmitry Stogov
cfd954f5f9 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16499: [JIT] Undefined to null coercion issues for return
2024-10-21 14:51:41 +03:00
Dmitry Stogov
920e3d6b70 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16499: [JIT] Undefined to null coercion issues for return
2024-10-21 14:51:31 +03:00
Dmitry Stogov
fe513655dc Fix GH-16499: [JIT] Undefined to null coercion issues for return 2024-10-21 14:50:50 +03:00
Dmitry Stogov
8b5668efef Fix invalid target opline with jit->reuse_ip active (#16457)
This is an alternative for #16440
2024-10-18 12:48:23 +03:00
Dmitry Stogov
c98c198623 Add test for GH-16355 (fixed by previous commit) 2024-10-17 17:37:52 +03:00
Dmitry Stogov
6896756929 Update IR
IR commit: abbdbf2ad7f66b02106f3b51602a21f10f508808
2024-10-17 17:31:47 +03:00
Dmitry Stogov
f68dcc5a1c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16393: Assertion failure in ext/opcache/jit/zend_jit.c:2897
2024-10-15 12:03:36 +03:00
Dmitry Stogov
dd45d85531 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16393: Assertion failure in ext/opcache/jit/zend_jit.c:2897
2024-10-15 12:01:40 +03:00
Dmitry Stogov
bf786d0d28 Fix GH-16393: Assertion failure in ext/opcache/jit/zend_jit.c:2897 2024-10-15 12:00:59 +03:00
Dmitry Stogov
3fcf8caca8 Update IR
IR commit: 88c71c9572bdd9dd8aed99c80ad4a54fcbcfe082
2024-10-07 21:18:35 +03:00
Arnaud Le Blanc
82f70dba7d Use original op_array when JIT compiling a Closure
zend_jit() assumes that Closure op_arrays have no scope, but this is not true
when using the hot counters, first exec, or trace triggers as they use the
executed op_array, which is in case of Closures is a copy, with a scope.

In the tracing JIT this problem is avoided as we fetch the original op_array
when compiling a Closure. Here I replicate this for the hot counters and first
exec triggers.

Fixes GH-16186
Closes GH-16200
2024-10-07 18:06:14 +02:00
Dmitry Stogov
64214d286b Update IR
IR commit: eff4b4109aed08d4864bd5bd7228575d8fd01158
2024-10-07 15:31:04 +03:00
Dmitry Stogov
ddc49153f1 Improve JIT TRACE coverage (#16171)
Now it's possible that PHP tracing JIT loses some parts of the "hot"
code. In case we have a root LOOP trace with an inlined call of some
function, and we get a SIDE exit inside that function - we recorded a
side trace, but finished it a the RETURN of the inlined function. As
result the opcodes betwee RETURN from SIDE trace and LOOP exit were not
covered by tracer and were executed in interpreter.

This patch introduces a "ret_depth" argument that prevents stopping
tracing on RETURN of such SIDE trace.
2024-10-02 19:27:31 +03:00
Dmitry Stogov
b8ac4ca19d Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix possible NULL dereference
2024-09-26 15:44:16 +03:00
Dmitry Stogov
8b7f64fa41 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix possible NULL dereference
2024-09-26 15:44:05 +03:00
Dmitry Stogov
24d5912a30 Fix possible NULL dereference 2024-09-26 15:43:42 +03:00
Niels Dossche
daba40c695 Fix GH-16009: Segmentation fault with frameless functions and undefined CVs
The frameless function handlers do not update the op variables when
handling the result is undefined. In this case this causes propagating
an UNDEF value into a temporary, which results in an extra undefined
variable warning for a temporary in this case.

The original issue also reports a crash in some cases, which is also
fixed by this patch.

Closes GH-16012.
2024-09-24 21:20:35 +02:00
Calvin Buckley
f5f05e886e Fix regression on systems built without JIT (#16024)
regressing commit: 654b787ee1

This was called if JIT was enabled or not. If not enabled, it'll result
in an undeclared function warning and maybe a bad time in the linker.
Gate the meat of this PHP-side function on if JIT is enabled (but keep
it existing so PHP userland code works with or without JIT, OFC).
2024-09-24 11:38:59 -03:00
Florian Engelhardt
3293fafa27 Add OPcache restart hook (#15590)
This hook will allow observing extensions to observe the actual OPcache restart.
2024-09-24 16:24:01 +02:00
Bob Weinand
654b787ee1 Add API to exempt function from being traced in JIT (#15559)
Internally accessible via zend_jit_blacklist_function / externally via opcache_jit_blacklist.
The functionality currently only affects tracing JIT, but may be extended to other JIT modes in future.
2024-09-24 14:20:38 +02:00
Dmitry Stogov
8f00430a2b Fix GH-15972: Assertion failure in ext/opcache/jit/zend_jit_vm_helpers.c with function JIT (#16001) 2024-09-24 10:24:08 +03:00
Dmitry Stogov
b2eff1f2ce Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15973: Segmentation fault in JIT mode 1135 (#16006)
2024-09-23 17:13:47 +03:00
Dmitry Stogov
e3507cba6f Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15973: Segmentation fault in JIT mode 1135 (#16006)
2024-09-23 17:09:17 +03:00
Dmitry Stogov
dc0987d154 Fix GH-15973: Segmentation fault in JIT mode 1135 (#16006) 2024-09-23 17:09:00 +03:00
Dmitry Stogov
a360b1757e Add test for GH-15903 2024-09-18 09:35:01 +03:00
Dmitry Stogov
9cb48c8fa1 Update IR
IR commit: 84a4b4259a0ea246f82e0d8a3d79032af75b5267

This fixes GH-15903: Core dumped in ext/opcache/jit/ir/ir_ra.c
2024-09-18 09:33:54 +03:00
Dmitry Stogov
36dfe634b0 Add test for GH-15909 (fixed by previous IR update) 2024-09-17 21:24:42 +03:00
Dmitry Stogov
718cff9bbb Update IR
IR commit: 4f02f1bdc5b4312b862e5e399fe9fb1cfe149d0f
2024-09-17 21:24:01 +03:00
Dmitry Stogov
1ce865244a Update IR
IR commit: d441328849f5172e6ad213cf0e42d77322238048
2024-09-17 16:15:38 +03:00
Arnaud Le Blanc
c65e042c0b Fix zend_get_property_info_for_slot() for lazy objects (#15855)
zend_get_property_info_for_slot(obj, slot) assumes that 'slot' belongs to 'obj', but that may not be the case for lazy proxies.

Fortunately, the property info is often already available in path when it is needed.

For other cases, I make zend_get_property_info_for_slot() aware of lazy objects, and add zend_get_property_info_for_slot_self() for cases where the 'slot' is known to belong to the object itself.

Fixes oss-fuzz #71446
2024-09-16 16:58:12 +02:00
Peter Kokot
888eb370cf Fix -Wundef/C4668 warnings (#15853)
- ZTS is either undefined or defined (to 1)
- PHP_WIN32 is either undefined or defined (to 1)
- HAVE_LIBEDIT is either undefined or defined (to 1)
2024-09-14 11:28:32 +02:00
Dmitry Stogov
98f07fcfca Fix more issues reported in GH-15852
* Fix incorrect register allocation

* Avoid IR binding/spilling conflict

* Add missing type guard
2024-09-12 20:19:11 +03:00
Niels Dossche
ded8fb79bd Fix UAF issues with PCRE after request shutdown
There are two related issues, each tested.

First problem:
What happens is that on the CLI SAPI we have a per-request pcre cache,
and on there the request shutdown for the pcre module happens prior to
the remaining live object destruction. So when the SPL object wants to
clean up the regular expression object it gets a use-after-free.

Second problem:
Very similarly, the non-persistent resources are destroyed after request
shutdown, so on the CLI SAPI the pcre request cache is already gone, but
if a userspace stream references a regex in the pcre cache, this breaks.

Two things that come immediately to mind:
  -  We could fix it by no longer treating the CLI SAPI special and just use
     the same lifecycle as the module. This simplifies the pcre module code
     a bit too. I wonder why we even have the separation in the first place.
     The downside here is that we're using more the system allocator
     than Zend's allocator for cache entries.
  -  We could modify the shutdown code to not remove regular expressions
     with a refcount>0 and modify php_pcre_pce_decref code such that it
     becomes php_pcre_pce_decref's job to clean up when the refcount
     becomes 0 during shutdown. However, this gets nasty quickly.

I chose the first solution here as it should be reliable and simple.

Closes GH-15064.
2024-09-11 18:49:19 +02:00
Dmitry Stogov
32d67855e6 Update IR
IR commit: 4cb5282c895908cfd4547ab460de86d189d15177

Fixes GH-15662: Segmentation fault in ext/opcache/jit/ir/ir_cfg.c
2024-09-11 16:03:38 +03:00
Niels Dossche
3665ab0118 Fix GH-15657: Segmentation fault in ext/opcache/jit/ir/dynasm/dasm_x86.h
The crash happens because the zend_persist.c code tries to JIT the hook's
op_array while the JIT buffer memory is still protected. This happens in
`zend_persist_property_info` called via `zend_persist_class_entry`
through the inheritance cache.

We shouldn't JIT the property hook code when persisting property info
for the inheritance cache.

This is a simple workaround by temporarily disabling the JIT so that the
property hook code is not JITted when persisting the property info.

An alternative solution would be to move the JITting of the property
hooks to a different place in zend_persist.c by doing an additional pass
over the classes.

Closes GH-15819.
2024-09-11 09:08:51 +02:00
Dmitry Stogov
7c8b3b2c96 Fix GH-15821: Core dumped in Zend/Optimizer/zend_inference.c:4062 2024-09-10 16:14:03 +03:00
Dmitry Stogov
bdcb2185aa Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15820: Core dumped with jit.opcache=1245
2024-09-10 15:45:00 +03:00
Dmitry Stogov
43202d2bfa Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15820: Core dumped with jit.opcache=1245
2024-09-10 15:44:24 +03:00
Dmitry Stogov
5cf045d357 Fix GH-15820: Core dumped with jit.opcache=1245 2024-09-10 15:42:23 +03:00
Niels Dossche
201c691fab Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix buffer size configuration for AArch64
2024-09-09 22:02:52 +02:00
Niels Dossche
f8486c7ddc Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix buffer size configuration for AArch64
2024-09-09 22:02:46 +02:00
Niels Dossche
bcd1f23b30 Fix buffer size configuration for AArch64 2024-09-09 22:02:39 +02:00
Niels Dossche
23db89538b Fix merge into master 2024-09-09 21:00:05 +02:00
Niels Dossche
90b91d3974 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15658: Segmentation fault in Zend/zend_vm_execute.h
2024-09-09 20:26:50 +02:00
Niels Dossche
d2a5c98797 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15658: Segmentation fault in Zend/zend_vm_execute.h
2024-09-09 20:26:44 +02:00