1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 10:12:18 +01:00
Commit Graph

2259 Commits

Author SHA1 Message Date
Dmitry Stogov
b932c267f8 Update IR
IR commit: 3d0124a06ee4321e1305f893b74840033d939e88
2025-03-20 01:10:56 +03:00
Niels Dossche
f4ba3564f5 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Correct check for maximum string length in JIT helpers
2025-03-13 23:49:42 +01:00
Niels Dossche
413938143b Fix GH-18037: SEGV Zend/zend_execute.c
A frameless icall with 3 arguments is a special case because it uses
OP_DATA, but this was not added to the list, so the opline pointed to
the wrong address resulting in UBSAN report or crash.

Closes GH-18048.
2025-03-13 23:48:24 +01:00
Niels Dossche
a7d2703246 Correct check for maximum string length in JIT helpers
This is a bit of a theoretical issue, but the maximum string length is
actually ZSTR_MAX_LEN instead of SIZE_MAX. The resulting check is a bit
slower but should still be relatively cheap.

Closes GH-18049.
2025-03-13 23:47:45 +01:00
Dmitry Stogov
ae67eb0490 Update IR
IR commit: 8bb0acca45a7b0f12691f4258e41462599efbd74
2025-03-13 03:07:43 +03:00
Dmitry Stogov
1b9d659c3f Fix register allocarion for result of ASSIGN_OBJ (#17994)
This fixes few failures in Symfony unit tests with function JIT
2025-03-07 19:28:51 +03:00
Dmitry Stogov
5885b9490c Fix function JIT for Wordpress unit tests 2025-03-07 02:30:30 +03:00
Dmitry Stogov
cc70838dc9 Merge IR
IR commit: 0441281e95ce9736131eddc71ce666389dcccd4b
2025-03-06 23:00:53 +03:00
Niels Dossche
f6c2e40a11 Fix GH-15834: Segfault with hook "simple get" cache slot and minimal JIT
The FETCH_OBJ_R VM handler has an optimization that directly enters into
a hook if it is a simpler getter hook. This is not compatible with the
minimal JIT because the minimal JIT will try to continue executing the
opcodes after the FETCH_OBJ_R.
To solve this, we check whether the opcode is still the expected one
after the execution of the VM handler. If it is not, we know that we are
going to execute a simple hook. In that case, exit to the VM.

Closes GH-17909.
2025-03-06 19:37:21 +01:00
Dmitry Stogov
f016caa312 Merge IR
IR commit: 1a02c4819f210a1f4548b83850ed7cd5c76c13aa
2025-03-03 23:48:08 +03:00
Niels Dossche
422e90db3b Fix branch target in zend_jit_push_call_frame() (#17949)
Introduced by accident in 3b4a58da44.
Will request a cherry-pick.
2025-02-28 09:20:02 +01:00
Dmitry Stogov
819b1988a0 Update IR
IR commit: ca93e781eaf6b0949690d3df272ecf44528ff4a8
2025-02-25 02:23:05 +03:00
Niels Dossche
3b4a58da44 Backport GH-17869 to PHP 8.3 JIT
Closes GH-17918.
2025-02-24 21:45:03 +01:00
Niels Dossche
5ede5415e1 Fix GH-17868: Cannot allocate memory with tracing JIT on 8.4.4
The generated code tries to initialize the run time cache for even
internal closures, but it should only initialize the run time cache for
user closures. We fix this by adding a check for the function type.
If `func` is known, then we can check the type at code generation time.

Closes GH-17869.
2025-02-24 19:36:13 +01:00
Dmitry Stogov
dd404dc419 Update IR
IR commit: 1499748be439e7f786c0ee2c4f738c126af57df8
2025-02-20 23:58:08 +03:00
Dmitry Stogov
352aca1ee1 Update IR
IR commit: 7f920cb660a1ef615a3059eab77b86ca1a43121e
2025-02-18 21:32:17 +03:00
Niels Dossche
34d8befe8d Fix GH-17747: Exception on reading property in register-based FETCH_OBJ_R breaks JIT
When read_property fails, it may return `&EG(uninitialized_zval)`, and
the exception is handled in the VM. The VM will try to
`zval_ptr_dtor_nogc` the result, but the result was never set, resulting
in dtor'ing garbage data. To solve this, we check when a different zval*
was returned and initialize the result with UNDEF. We don't need to copy
as the slow_ex handler return values are used directly in a register.

Closes GH-17749.
2025-02-11 21:55:23 +01:00
Dmitry Stogov
9fb355b863 Update IR
IR commit: 8ec4979470fe2a123d0e56da92aa8d5d19b6e54c
2025-02-10 16:47:47 +03:00
Dmitry Stogov
c730175be8 IR Update
IR commit: 36329a0398ff57929c51c52084027730a75b9862
2025-02-06 02:04:03 +03:00
Niels Dossche
78da288222 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17577: JIT packed type guard crash
2025-02-03 19:35:32 +01:00
Niels Dossche
0c3cf1f311 Fix GH-17577: JIT packed type guard crash
When a guard check is created for a variable to check if it's a packed array,
it is possible that there was no prior type check for that variable.
This happens in the global scope for example when the variable aliases.
In the test, this causes a dereference of address 8 because the integer
element in `$a` is interpreted as an array address.

This patch adds a check to see if the guard is handled.
If we were not able to determine or guard the type then we also cannot know the array is packed.

Closes GH-17584.
2025-02-03 19:34:39 +01:00
Niels Dossche
6d6380c09d Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17654: Multiple classes using same trait causes function JIT crash
2025-02-03 19:28:20 +01:00
Niels Dossche
f88445bdf8 Fix GH-17654: Multiple classes using same trait causes function JIT crash
This test has two classes that use the same trait. In function JIT mode
the same cache slot will be used. This causes problems because it is
primed for the first class and then reused for the second class,
resulting in an incorrect type check failure.

The current check for a megamorphic trait call requires current_frame to
not be NULL, but this is only set in tracing mode and not in function
mode.

This patch corrects the check.

Closes GH-17660.
2025-02-03 19:21:15 +01:00
Dmitry Stogov
63965f1de5 Update IR
IR commit: 02909bc123845fc2c41ec333b44b6f5ea1a196fe
2025-01-22 18:30:33 +03:00
Dmitry Stogov
9aaa469f99 Update IR
IR commit: d6d7fc489137aab218b04b59d770b497c5ae3832
2025-01-15 02:45:24 +03:00
Niels Dossche
3524702fe1 Fix GH-17428: Assertion failure ext/opcache/jit/zend_jit_ir.c:8940
The code to update the call_level in that case skips the opline itself,
as that's handled by the tail handler, and then wants to set the opline
to the last opline of the block because the code below the switch will
update the call_level for that opline.
However, the test has a block with a single opline (THROW). The block
after that has ZEND_INIT_FCALL, because `i` points to ZEND_INIT_FCALL
now, it erroneously causes the call_level after the switch.

Closes GH-17438.
2025-01-14 22:37:41 +01:00
Niels Dossche
e8fce295bc Backport fix GH-17307
This is a backport of GH-17319 to fix GH-17307 on lower branches.

Closes GH-17424.
2025-01-10 18:24:25 +01:00
Dmitry Stogov
4763193567 Update IR
IR commit: e445f57f3a936584db28489a49098d52f03388a7
2025-01-10 00:34:58 +03:00
Niels Dossche
28b448ac20 Fix GH-17307: Internal closure causes JIT failure
`bcadd(...)` is a closure for an internal function, and
`zend_jit_push_call_frame` takes into account both last_var and the
difference in argument numbers not only for user code but also for
internal code. However, this is inconsistent with
`zend_vm_calc_used_stack`, causing argument corruption.
Making this consistent fixes the issue.

I could only reproduce the assertion failure when using Valgrind.

Closes GH-17319.
2025-01-09 19:59:38 +01:00
Niels Dossche
c790c5b2e7 Generate inline frameless icall handlers only if the optimization level is set to inline 2025-01-09 19:59:10 +01:00
Niels Dossche
72184abd2f Fix GH-15981: Segfault with frameless jumps and minimal JIT
Minimal JIT shouldn't generate a call to the complex handler, but
instead rely on the VM and then check for a two-way jump.
This moves the frameless codegen under the check `JIT_G(opt_level) >=
ZEND_JIT_LEVEL_INLINE`.
2025-01-09 19:59:03 +01:00
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
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
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
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