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

5923 Commits

Author SHA1 Message Date
Ilija Tovilo
2ad778bc76 Fix missing GC_PERSISTENT_LOCAL flag on accel_globals.key 2025-01-28 12:55:09 +01:00
Ilija Tovilo
8ea9b04a23 Fix inline zend_string using struct padding
As explained by Snape3058: On 64-bit machines, we typically have 7 bytes
of padding between the zend_string.val[0] char and the following char[].
This means that zend_string.val[1-7] write to and read from the struct
padding, which is a bad idea.

Allocate the given string separately instead.

Fixes GH-17564
Closes GH-17576
2025-01-27 19:50:38 +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
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
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
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
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
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
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
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
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
Niels Dossche
0bf74bf9d8 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16770: Tracing JIT type mismatch when returning UNDEF
2024-11-14 22:34:05 +01:00
Niels Dossche
cbb3b9371d Fix GH-16770: Tracing JIT type mismatch when returning UNDEF
When returning an UNDEF value, it actually becomes NULL.
The following code took this into account:
28344e0445/ext/opcache/jit/zend_jit_trace.c (L2196-L2199)

But the stack does not update the type to NULL, causing a mismatch.

Closes GH-16784.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2024-11-14 22:33:06 +01:00
Dmitry Stogov
b9c6f07713 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix incorrect handling of ZEND_ACC_FINAL flag in JIT (#16778)
2024-11-13 14:39:18 +03:00
Dmitry Stogov
19809a526b Fix incorrect handling of ZEND_ACC_FINAL flag in JIT (#16778) 2024-11-13 14:38:54 +03: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
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
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
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
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
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
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
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
Niels Dossche
c1ffd4b484 Fix GH-15658: Segmentation fault in Zend/zend_vm_execute.h
Implement a minimal ZEND_MATCH handler using a tail call.

Closes GH-15782.
2024-09-09 20:26:16 +02:00
Niels Dossche
75f5cbf89e Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15661: Access null pointer in Zend/Optimizer/zend_inference.c
2024-09-09 20:12:01 +02:00
Niels Dossche
86ef8d5466 Fix GH-15661: Access null pointer in Zend/Optimizer/zend_inference.c
Closes GH-15666.
2024-09-09 20:10:16 +02:00
Dmitry Stogov
94f5ef09a0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix OPcache tests under specific conditions
2024-09-09 10:00:41 +03:00
Go Kudo
d966c296d0 Fix OPcache tests under specific conditions 2024-09-09 10:00:25 +03:00
Dmitry Stogov
fb2266b1ca Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix OPcache tests under specific conditions
2024-09-09 09:56:37 +03:00
Go Kudo
bca5f6e74f Fix OPcache tests under specific conditions 2024-09-09 09:55:52 +03:00
Dmitry Stogov
be8589651d Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15652: Segmentation fault in the Zend engine when JIT enabled (#15717)
2024-09-02 21:55:40 +03:00
Dmitry Stogov
1e78cf941c Fix GH-15652: Segmentation fault in the Zend engine when JIT enabled (#15717) 2024-09-02 21:55:19 +03:00
Dmitry Stogov
b55816e9d1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Don't set IS_STR_PERMANENT flag for strings stored in the file cache (#15643)
2024-08-30 01:01:22 +03:00
Dmitry Stogov
afba2010c0 Don't set IS_STR_PERMANENT flag for strings stored in the file cache (#15643) 2024-08-30 00:59:06 +03:00