1
0
mirror of https://github.com/php/php-src.git synced 2026-03-25 16:52:18 +01:00
Commit Graph

6308 Commits

Author SHA1 Message Date
Niels Dossche
f4fb77ed61 Fix GH-17257: UBSAN warning in ext/opcache/jit/zend_jit_vm_helpers.c
EX(opline) / opline can be stale if the IP is not stored, like in this
case on a trace enter. We always need to make sure that the opline is up
to date to make sure we don't use stale data.

Closes GH-17260.
2024-12-26 12:26:48 +01:00
Niels Dossche
e45fdd2f89 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17246: GC during SCCP causes segfault
2024-12-24 14:23:33 +01:00
Niels Dossche
df6db27580 Fix GH-17246: GC during SCCP causes segfault
This bug happens because of a nested `SHM_UNPROTECT()` sequence.
In particular:
```
unprotect memory at ext/opcache/ZendAccelerator.c:2127
protect memory at ext/opcache/ZendAccelerator.c:2160
unprotect memory at ext/opcache/ZendAccelerator.c:2164
unprotect memory at ext/opcache/jit/zend_jit_trace.c:7464
^^^ Nested
protect memory at ext/opcache/jit/zend_jit_trace.c:7591
^^^ Problem is here: it should not protect again due to the nested unprotect
protect memory at ext/opcache/ZendAccelerator.c:2191
^^^ This one should actually protect, not the previous one
```

The reason this nesting happen is because:
1. We try to include the script, this eventually calls `cache_script_in_shared_memory`
2. `zend_optimize_script` will eventually run SCCP as part of the DFA pass.
3. SCCP will try to replace constants, but can also run destructors when a partial array is destructed here:

4e9cde758e/Zend/Optimizer/sccp.c (L2387-L2389)

In this case, this destruction invokes the GC which invokes the tracing JIT,
leading to the nested unprotects.

This patch disables the GC to prevent invoking user code, as user code
is not supposed to run during the optimizer pipeline.

Closes GH-17249.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2024-12-24 14:22:48 +01:00
Dmitry Stogov
f8d2e00964 Fix GH-17190: Assertion failure ext/opcache/jit/ir/ir_gcm.c (#17221) 2024-12-20 10:59:33 +03:00
Dmitry Stogov
33c12e0776 Update IR
IR commit: 79483000c2a4b918221fa3097ca47b48b3519447
2024-12-19 20:29:35 +03:00
Dmitry Stogov
6666cc83c5 Fix RC inference of op1 of FETCH_OBJ and INIT_METHOD_CALL
Fixes GH-17151
Closes GH-17152
2024-12-18 19:08:51 +01:00
Ilija Tovilo
cbe9d67efc Add tests for GH-17151 2024-12-18 19:07:59 +01:00
Niels Dossche
2104097a79 Fix GH-17140 (Assertion failure in JIT trace exit with ZEND_FETCH_DIM_FUNC_ARG)
ZEND_FETCH_DIM_FUNC_ARG should also be repeated on undefined access,
consistent to how ZEND_FETCH_DIM_R is handled. The opcode was just
missing from the assertion list.

Closes GH-17148.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2024-12-16 19:46:11 +01:00
Dmitry Stogov
ccc6c0f78c Fix GH-15709: Crashing tests on Windows x64 (#17095)
This is a quick fix for the problem.
It'll work while all the JIT-ed functions have the same "fixed stack frame".
Unwinder uses hard-coded unwind data for this "fixed stack frame".

* Preallocate space for Win64 shadow args

* typo

* Setup unwinder for JIT functions

* Revert "Dynamically xfail test case which fails on CI"

This reverts commit 7cc327fd5a.

* Revert "Dynamically xfail test case which fails on CI"

This reverts commit bdde797159.

* Revert "Dynamically xfail test cases which fail on CI (GH-15710)"

This reverts commit 6d5962074f.

* Remove XFAIL sections

* Add hard-coded SEH unwind data for EXITCALL

* Fix unwind data

* Fix Windows multi-process support

* Typo
2024-12-13 02:05:45 +03:00
Ilija Tovilo
901ce61105 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix ZEND_MATCH_ERROR misoptimization
2024-12-12 13:11:29 +01:00
Ilija Tovilo
cdfd960150 Fix ZEND_MATCH_ERROR misoptimization
op1 of ZEND_MATCH_ERROR, which refers to the match expression, is not freed by
MATCH_ERROR itself. Instead, it is freed by ZEND_HANDLE_EXCEPTION. For normal
control flow, a FREE is placed at the end of the match expression.

Since FREE may appear after MATCH_ERROR in the opcode sequence, we need to
correctly handle op1 of MATCH_ERROR as alive.

Fixes GH-17106
Closes GH-17108
2024-12-12 13:10:34 +01:00
Ilija Tovilo
792f63df45 Fix unstable get_iterator pointer for hooked classes in shm on Windows
Closes GH-17034
2024-12-09 17:14:19 +01:00
Christoph M. Becker
5eed224c6c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  opcache_get_configuration() properly reports jit_prof_threshold
2024-12-09 11:46:51 +01:00
Christoph M. Becker
3702f9783b opcache_get_configuration() properly reports jit_prof_threshold
The `jit_prof_threshold` is a float, supposed to be in range [0, 1],
and usually very small (the default is 0.005).  Reporting it as int
is meaningless.

Closes GH-17077.
2024-12-09 11:45:16 +01:00
Dmitry Stogov
6bac907cb1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Backport fix for GH-9011 (#17052)
2024-12-05 18:32:18 +03:00
Dmitry Stogov
9d4f5f0762 Backport fix for GH-9011 (#17052)
* Backport fix for GH-9011

* Fix build
2024-12-05 18:32:02 +03:00
Dmitry Stogov
5ab2c02ea1 Fix GH-9011: Assertion failure with tracing JIT (#17042)
* Fix GH-9011: Assertion failure with tracing JIT

* Temporay SKIP the test on 64-bit Windows because of GH-15709
2024-12-04 19:49:17 +03:00
Dmitry Stogov
89b82ef709 Fix GH-16996: 8.4 tracing JIT phpseclib failures (#17030)
* Fix GH-16996: 8.4 tracing JIT phpseclib failures

This prevents conflicts caused by spilling to bound PHP stack slots by
creating copies.

* Fix build
2024-12-03 20:43:15 +03:00
Dmitry Stogov
c5ce74c88c Fix GH-17003: Pecl 8.4 tracing JIT crash (#17032) 2024-12-03 20:42:27 +03:00
Dmitry Stogov
f04a9f466f Update IR
IR commit: 1a41bddcf0a41b9a3866d00b57591b3684c88443
2024-12-03 13:01:31 +03:00
Dmitry Stogov
03bb112fb2 Fix GH-16984: function JIT overflow bug (#17015) 2024-12-02 13:30:26 +03:00
Dmitry Stogov
5ed438fe07 Update IR
IR commit: 673308a039eed5a2fdf4a2783b3dd3d6010a8c19
2024-11-29 16:28:27 +03:00
Dmitry Stogov
6fca900cc7 Update IR
IR commit: 7c26e26126123beac8dbaf811d5eac8d789d584f
2024-11-29 02:39:33 +03:00
Dmitry Stogov
b89d7ff92a Fix GH-16821: runtime error: member access within misaligned address when running phpseclib tests (#16951) 2024-11-27 00:43:45 +03:00
Niels Dossche
ed556939df Extract call_level conditions out to separate functions (#16949)
These are repeated a couple of times, so centralise it in 2 functions to
reduce repetition and make updating this less error-prone.
2024-11-26 21:22:12 +01:00
Dmitry Stogov
d31de85f5f Avoid possible spill conflict (one of the problem that caused GH-16821) (#16947) 2024-11-26 21:44:15 +03:00
Niels Dossche
de30ba5042 Fix GH-16879: JIT dead code skipping does not update call_level
We intend to execute `MATCH_ERROR` in the VM and return to trace a hot
function in BB1. We generate a tail handler and skip all remaining
oplines of BB0. That means the `INIT_FCALL` in BB0 is missed and
`call_level` is not increased to 1. This leads to the assertion
failure.
This patch fixes the issue by updating the `call_level` for the skipped
oplines.

Closes GH-16939.
2024-11-26 19:27:17 +01:00
Dmitry Stogov
7892a0ec8a Fix GH-16913: 8.4 function JIT memory corruption (#16943)
with '#' will be ignored, and an empty message aborts the commit.
2024-11-26 16:59:57 +03:00
Niels Dossche
f4ca6d2794 Fix GH-16902: Set of opcache tests fail zts+aarch64 (8.4+)
Accompanying IR PR: https://github.com/dstogov/ir/pull/95

Closes GH-16924.
2024-11-25 19:51:01 +01:00
Niels Dossche
d50a56139c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16902: Set of opcache tests fail zts+aarch64 (8.2-8.3)
2024-11-25 19:50:05 +01:00
Niels Dossche
de96b43d2a Fix GH-16902: Set of opcache tests fail zts+aarch64 (8.2-8.3)
Closes GH-16925.
2024-11-25 19:49:33 +01:00
Dmitry Stogov
ba8e3e1d79 Update IR
IR commit: ff7ee6c1e6090ba0ba7b47cb77939518304fab6b
2024-11-25 10:29:41 +03:00
Christoph M. Becker
da81b5c8d2 Reapply "Merge branch 'PHP-8.3' into PHP-8.4"
This reverts commit 83ca37483c, and
fixes the previous bad merge.
2024-11-20 23:24:43 +01:00
Christoph M. Becker
83ca37483c Revert "Merge branch 'PHP-8.3' into PHP-8.4"
This reverts commit ae62779386, reversing
changes made to 19e685ecc4.

This was a bad merge; I'll have a look shortly.
2024-11-20 19:45:36 +01:00
Christoph M. Becker
ae62779386 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16851: JIT_G(enabled) not set correctly on other threads
2024-11-20 19:14:57 +01:00
Christoph M. Becker
58ed759ba7 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16851: JIT_G(enabled) not set correctly on other threads
2024-11-20 19:12:40 +01:00
Dylan K. Taylor
ff3b4eca0e Fix GH-16851: JIT_G(enabled) not set correctly on other threads
There doesn't seem to be a thread post-startup hook that runs after
zend_startup_cb() that could be used for this

this fix is similar to accel_startup_ok() as seen here: fc1db70f10/ext/opcache/ZendAccelerator.c (L2631-L2634)

Closes GH-16853.
2024-11-20 19:11:44 +01:00
Dmitry Stogov
d0c336a666 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Use the immutable twin of temporary op_array (#16861)
2024-11-19 20:55:40 +03:00
Dmitry Stogov
d1a9281814 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Use the immutable twin of temporary op_array (#16861)
2024-11-19 20:55:32 +03:00
Dmitry Stogov
ef5844a1ca Use the immutable twin of temporary op_array (#16861) 2024-11-19 20:55:15 +03:00
Dmitry Stogov
c6c3d9fa5a Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Backport JIT fix: set valid EX(opline) before calling gc_possible_root() (#16858)
2024-11-19 18:04:15 +03:00
Dmitry Stogov
6167c64782 Backport JIT fix: set valid EX(opline) before calling gc_possible_root() (#16858) 2024-11-19 18:03:54 +03:00
Christoph M. Becker
e44b7625c5 Fix GH-16839: Error on building Opcache JIT for Windows ARM64
OPcache JIT does not support Windows ARM64, so we should not allow
`--enable-opcache-jit` in the first place.

Due to the way `ARG_ENABLE()` is handled on Windows, we do not attempt
to suppress the configure option, but just do not enable JIT when the
user attempts to, and adapt the help text.

Closes GH-16841.
2024-11-18 23:27:54 +01:00
Dmitry Stogov
997431dea2 JIT: Set valid EX(opline) before calling gc_possible_root() 2024-11-18 19:31:26 +03:00
Dmitry Stogov
159b71c0f4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fixed test
2024-11-18 15:35:13 +03:00
Dmitry Stogov
5198bcc561 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fixed test
2024-11-18 15:35:09 +03:00
Dmitry Stogov
71403558d3 Fixed test 2024-11-18 15:34:55 +03:00
Dmitry Stogov
e55bf9a2ea Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16829: Segmentation fault with opcache.jit=tracing enabled on aarch64
2024-11-18 14:34:55 +03:00
Dmitry Stogov
5575703fb3 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16829: Segmentation fault with opcache.jit=tracing enabled on aarch64
2024-11-18 14:34:42 +03:00
Dmitry Stogov
79aaeeafe5 Fix GH-16829: Segmentation fault with opcache.jit=tracing enabled on aarch64 2024-11-18 14:27:08 +03:00