Commit graph

19466 commits

Author SHA1 Message Date
Tim Düsterhus
f37b165403
Fix #[\Deprecated] for __call() and __callStatic() (#17592)
* Fix `#[\Deprecated]` for `__call()` and `__callStatic()`

Fixes php/php-src#17597.

* Do not duplicate the `attributes` table in `zend_get_call_trampoline_func()`
2025-01-27 13:41:41 +01:00
Niels Dossche
0b12db6afa
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix may_have_extra_named_args flag for ZEND_AST_UNPACK
2025-01-21 19:27:19 +01:00
Niels Dossche
0b3e637aec
Fix may_have_extra_named_args flag for ZEND_AST_UNPACK
The check for `!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)` is
performed after `fbc` is set to NULL, so this always returns true.
This results in `ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS` always being
set for unpack sends. Fix it by moving the flag updates to the point
before setting `fbc` to NULL.

Closes GH-17534.
2025-01-21 19:26:49 +01:00
Niels Dossche
25543b4566
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17408: Assertion failure Zend/zend_exceptions.c
2025-01-21 08:21:13 +01:00
Niels Dossche
5344bcca97
Fix GH-17408: Assertion failure Zend/zend_exceptions.c
`zend_test_create_throwing_resource` sets the exception in the `test`
call frame and unwinds to `main`. It then throws for the `resource`
variable and verifies that the exception opline is set. However, it
wasn't set in `main`, it was set at the `test` call frame and rethrown later.
The assertion is too conservative, but the end result is right, so drop
the assertion.

Closes GH-17533.

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2025-01-21 08:20:38 +01:00
Ilija Tovilo
3c138641e1
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Relax final+private warning for trait methods with inherited final
2025-01-13 16:46:43 +01:00
Ilija Tovilo
a6a290d541
Relax final+private warning for trait methods with inherited final
Fixes GH-17214
Closes GH-17381
2025-01-13 16:46:01 +01:00
Ilija Tovilo
147e9c808c
__PROPERTY__ does not work in all constant expression contexts
Fixes GH-17222
Closes GH-17378
2025-01-13 16:42:38 +01:00
Niels Dossche
3eb79e146f
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17409: Assertion failure Zend/zend_hash.c:1730
  NEWS
  Add comment
  Fix GH-16892: ini_parse_quantity() fails to parse inputs starting with 0x0b
  Fix GH-16886: ini_parse_quantity() fails to emit warning for 0x+0
  Merge duplicate code blocks
2025-01-09 19:54:46 +01:00
Niels Dossche
a2b8204880
Add comment
Closes GH-17274.
2025-01-09 19:52:13 +01:00
Niels Dossche
7626e88de7
Fix GH-16892: ini_parse_quantity() fails to parse inputs starting with 0x0b 2025-01-09 19:51:18 +01:00
Niels Dossche
2c267722b3
Fix GH-16886: ini_parse_quantity() fails to emit warning for 0x+0 2025-01-09 19:51:17 +01:00
Niels Dossche
e6e2ec56ab
Merge duplicate code blocks
This makes the code less error-prone.
2025-01-09 19:51:17 +01:00
Niels Dossche
71493623f4
Fix GH-17234: Numeric parent hook call fails with assertion
The current code expects the property name to be a string, but it can
also be a number via the {} syntax. Handle this consistently to a string
by using zval_get_string which will do the type coercion and refcount
update (instead of assuming string and doing an explicit string copy).

Closes GH-17236.
2025-01-07 19:21:22 +01:00
Eric Mann
717b75cb43
PHP-8.3 is now for PHP-8.3.17-dev 2024-12-31 08:46:21 -08:00
Saki Takamachi
fc10c1d13d
PHP-8.4 is now for PHP 8.4.4-dev 2025-01-01 00:49:12 +09:00
Niels Dossche
627432785e
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17216: Trampoline crash on error
2024-12-21 00:26:23 +01:00
Niels Dossche
2c3b56ded0
Fix GH-17216: Trampoline crash on error
The error handling is incomplete on argument cleanup.
1. The fci is not cleared which means that zend_free_trampoline() is
   never called.
2. The cleaning for extra named arguments was missing, resulting in
   memory leak.

Closes GH-17219.
2024-12-21 00:25:06 +01:00
Arnaud Le Blanc
32148e9b10
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add observer temporary to dl'ed functions
2024-12-20 18:50:16 +01:00
Arnaud Le Blanc
9e7932b292
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add observer temporary to dl'ed functions
2024-12-20 18:46:55 +01:00
Arnaud Le Blanc
6f579934f0
Add observer temporary to dl'ed functions
When observer is enabled, we normally add an extra temporary to all
functions, to store the previously observed frame. However, this is done in
zend_observer_post_startup() so it doesn't happen to dl'ed() functions.

One possible fix would be to move that from zend_observer_post_startup()
to zend_register_functions(), but this would be too early: Observer may
not be enabled when zend_register_functions() is called, and may still be
enabled later.

However, when zend_register_functions() is called at run-time (during dl()),
we know definitively whether observer is enabled.

Here I update zend_register_functions() to add a temporary to dl'ed()
functions when observer is enabled.

Fixes: GH-17211
Closes: GH-17220
2024-12-20 18:45:34 +01: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
f0441744db
Fix incorrect dynamic prop offset in hooked prop iterator
Fixes GH-17200
Closes GH-17203
2024-12-18 18:47:48 +01:00
Niels Dossche
160a4a65ad
Export visibility for promoted property (8.3) 2024-12-17 19:14:07 +01:00
Niels Dossche
d4778224ca
Add test for GH-17101 2024-12-17 19:06:10 +01:00
Niels Dossche
3f0f7ab7df
Print hooks in parameter exports 2024-12-17 19:06:10 +01:00
Niels Dossche
0cba85b54d
Fix property hook name mismatch 2024-12-17 19:06:10 +01:00
Niels Dossche
6920aa2ae6
Extract hook export code 2024-12-17 19:06:10 +01:00
Niels Dossche
6f41bfd1c7
Export visibility for promoted property 2024-12-17 19:06:09 +01:00
Niels Dossche
08b14a57b8
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17162: zend_array_try_init() with dtor can cause engine UAF
2024-12-15 20:12:12 +01:00
Niels Dossche
ee0daa59db
Fix GH-17162: zend_array_try_init() with dtor can cause engine UAF
Closes GH-17167.
2024-12-15 20:11:40 +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
Ilija Tovilo
84917300b2
Fix duplicate dynamic properties in hooked object iterator properties table
Ouch, Z_TRY_ADDREF_P() uses pz twice... Also make sure we actually reserve
enough Buckets for all dynamic properties.

Fixes OSS-Fuzz #382922236
Closes GH-17085
2024-12-09 17:07:57 +01: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
Jakub Zelenka
b1e3dcf88a
PHP-8.3 is now for PHP 8.3.16-dev 2024-12-03 18:45:43 +01:00
Calvin Buckley
f12cd1985e
PHP-8.4 is now for PHP-8.4.3-dev 2024-12-03 11:27:18 -04:00
Sergey Panteleev
7fbeee0c2f
PHP-8.2 is now for PHP 8.2.28-dev 2024-12-03 16:48:02 +03:00
Christoph M. Becker
ba7dee5676
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix potential OOB read in zend_dirname() on Windows
2024-11-29 22:11:00 +01:00
Christoph M. Becker
65070bb46c
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix potential OOB read in zend_dirname() on Windows
2024-11-29 22:09:40 +01:00
Christoph M. Becker
94fa2a4ce1
Fix potential OOB read in zend_dirname() on Windows
Only on Windows `IS_SLASH_P()` may read the previous byte, and so may
in unlikely cases read one byte out of bounds.  Since `IS_SLASH_P()` is
in a public header (albeit not likely to be used by external extensions
or SAPIs), we introduce `IS_SLASH_P_EX()` which accepts a second
argument to prevent that OOB read.

It should be noted that the PHP userland function `dirname()` is not
affected by this issue, since it does not call `zend_dirname()` on
Windows.

Closes GH-16995.
2024-11-29 22:08:06 +01:00
Pierrick Charron
fb919e885a
PHP-8.4 is now for PHP 8.4.2-dev 2024-11-28 11:31:26 -05:00
Niels Dossche
8fdcd9f051
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix is_zend_ptr() huge block comparison
2024-11-26 19:24:47 +01:00
Niels Dossche
02b1056714
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix is_zend_ptr() huge block comparison
2024-11-26 19:24:31 +01:00
Niels Dossche
18674e39ad
Fix is_zend_ptr() huge block comparison
We should compare the block memory, not the block metadata (See
zend_mm_add_huge_block).
This caused random test failure for ext/ffi/tests/gh14626.phpt when the
malloc() performed by the FFI code lies close to the block metadata, and
the size of the block is large enough.

This was reported by https://github.com/php/php-src/issues/16902#issuecomment-2498310452

Closes GH-16938.
2024-11-26 19:24:05 +01:00
Arnaud Le Blanc
c310be09ed
Fix setRawValueWithoutLazyInitialization() and skipLazyInitialization() on initialized proxy
Normally, accesses to properties marked as lazy trigger the object's
initialization, or forward to a real instance if the object is an initialized
proxy.

The purpose of ReflectionProperty::setRawValueWithoutLazyInitialization() and
ReflectionProperty::skipLazyInitialization() is to bypass auto-initialization,
so that some properties can be initialized without triggering initialization.

However, when the object is an initialized proxy, these methods would
unexpectedly update the proxy.

Here I make sure that these methods have an effect on the real instance, when
the object is an initialized proxy.

Fixes GH-16344
2024-11-26 14:04:58 +01:00
Saki Takamachi
1fd82aa13a
PHP-8.4 is now for PHP 8.4.1-dev 2024-11-20 17:19:18 +09:00
Niels Dossche
e00d684420
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16630: UAF in lexer with encoding translation and heredocs
2024-11-18 19:59:08 +01:00