1
0
mirror of https://github.com/php/php-src.git synced 2026-03-30 12:13:02 +02:00
Commit Graph

19349 Commits

Author SHA1 Message Date
Calvin Buckley
1f914f9084 Update versions for PHP 8.4.0RC2 2024-10-08 10:57:40 -03:00
Ilija Tovilo
d76ef13757 Fix various hooked object iterator issues
Fixes GH-16185
Closes GH-16281
2024-10-08 13:35:33 +02:00
Niels Dossche
b24cc7386b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fixed GH-16233: Observer segfault when calling user function in internal function via trampoline
2024-10-07 17:18:32 +02:00
Niels Dossche
0338008852 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fixed GH-16233: Observer segfault when calling user function in internal function via trampoline
2024-10-07 17:17:27 +02:00
Niels Dossche
e715dd0afb Fixed GH-16233: Observer segfault when calling user function in internal function via trampoline
In the test, I have an internal `__call` function for `_ZendTestMagicCallForward` that calls the global function with name `$name` via `call_user_function`.
Note that observer writes the pointer to the previously observed frame in the last temporary of the new call frame (`*prev_observed_frame`).

The following happens:
First, we call `$test->callee`, this will be handled via a trampoline with T=2 for the two arguments. The call frame is allocated at this point. This call frame is not observed because it has `ZEND_ACC_CALL_VIA_TRAMPOLINE` set. Next we use `ZEND_CALL_TRAMPOLINE` to call the trampoline, this reuses the stack frame allocated earlier with T=2, but this time it is observed. The pointer to the previous frame is written outside of the call frame because `T` is too small (should be 3). We are now in the internal function `_ZendTestMagicCallForward::__call` where we call the global function `callee`. This will push a new call frame which will overlap `*prev_observed_frame`. This value gets overwritten by `zend_init_func_execute_data` when `EX(opline)` is set because `*prev_observed_frame` overlaps with `EX(opline)`. From now on, `*prev_observed_frame` is corrupted. When `zend_observer_fcall_end` is called this will result in reading wrong value `*prev_observed_frame` into `current_observed_frame`. This causes issues in `zend_observer_fcall_end_all` leading to the segfault we observe.

Despite function with `ZEND_ACC_CALL_VIA_TRAMPOLINE` not being observed, the reuse of call frames makes problems when `T` is not large enough.
To fix this, we make sure to add 1 to `T` if `ZEND_OBSERVER_ENABLED` is true.

Closes GH-16252.
2024-10-07 17:16:43 +02:00
Arnaud Le Blanc
c1ea9b173f Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  NEWS for GH-16196
  NEWS for GH-16196
  Handle references properties of the Exception class
2024-10-07 15:04:24 +02:00
Arnaud Le Blanc
498e88489e Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  NEWS for GH-16196
  Handle references properties of the Exception class
2024-10-07 15:03:55 +02:00
Arnaud Le Blanc
c2115a43e3 Handle references properties of the Exception class
Fixes GH-16188
Closes GH-16196
2024-10-07 15:03:31 +02:00
Christoph M. Becker
6f7f32c330 Declare zend_call_stack_size_error() as ZEND_API
This is necessary at least on Windows to be able to actually call the
function from a different module (in this case php8phpdbg.dll could not
be build).

Closes GH-16204.
2024-10-03 22:46:53 +02:00
Arnaud Le Blanc
443aa29dbe Support stack limit in phpdbg SAPI
Fixes GH-16041
Closes GH-16055
2024-10-03 15:22:51 +02:00
Arnaud Le Blanc
c9dfb77446 Deny resetting an object as lazy during property iteration
Supporting object reset while its properties are being iterated would increase
complexity for little benefit. Furthermore it may not be possible to ensure a
consistent behavior between ghosts and proxies (wrt to iteration position).

Iteration is detected by checking if the object's properties ht has iterators.
This requires refactoring the hooked get_iterator() implementation to ensure
that it creates a properties ht iterator immediately.

Closes GH-15960
2024-10-03 15:12:21 +02:00
Arnaud Le Blanc
3151117987 Ensure to initialize lazy object in foreach
foreach() by-passes the get_properties() handler and did not always trigger
initialization.
2024-10-03 15:12:21 +02:00
Arnaud Le Blanc
52fec6958c Do not null out obj->properties when resetting object
Engine expects the properties ht to be separated, assigned a new ht, or resized,
but never to be nulled.
2024-10-03 15:12:21 +02:00
Arnaud Le Blanc
4d7fcea5da Fix handling of undef property during foreach by ref on hooked class 2024-10-03 15:12:21 +02:00
Niels Dossche
577eb68212 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-15169: stack overflow when var serialization in ext/standard/var
2024-10-02 21:32:20 +02:00
Niels Dossche
bd724bdf42 Fix GH-15169: stack overflow when var serialization in ext/standard/var
Adding a stack check here as I consider serialization to be a more
sensitive place where erroring out with an exception seems appropriate.

Closes GH-16159.
2024-10-02 21:30:59 +02:00
Arnaud Le Blanc
bc317d3afc Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [ci skip] NEWS for GH-16025
  [ci skip] NEWS for GH-16025
  Fix assertion failure in generator dtor (#16025)
2024-10-02 12:33:06 +02:00
Arnaud Le Blanc
7e6616cafb Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS for GH-16025
  Fix assertion failure in generator dtor (#16025)
2024-10-02 12:31:21 +02:00
Arnaud Le Blanc
6e55f4df23 Fix assertion failure in generator dtor (#16025) 2024-10-02 12:29:19 +02:00
Arnaud Le Blanc
ab72fbadd9 Fix use-after-free during lazy object initialization (#16004) 2024-10-02 12:15:36 +02:00
Arnaud Le Blanc
d093c10caf Fix reuse of dtor fiber during shutdown (#16026) 2024-10-02 12:11:10 +02:00
Tim Düsterhus
a1cc091808 reflection: Fix the return value of ReflectionFunction::{getNamespaceName,inNamespace}() for closures (#16129)
* reflection: Fix the return value of ReflectionFunction::{getNamespaceName,inNamespace}() for closures

Fixes GH-16122

* reflection: Clean up implementation of `ReflectionFunctionAbstract::inNamespace()`

* reflection: Clean up implementation of `ReflectionFunctionAbstract::getNamespaceName()`
2024-09-30 16:33:46 +02:00
Ilija Tovilo
bc07a8a28a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix printing backtrace of fake generator frame
2024-09-27 17:37:07 +02:00
Ilija Tovilo
8c556b211d Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix printing backtrace of fake generator frame
2024-09-27 17:35:55 +02:00
Ilija Tovilo
706bcdbc1a Fix printing backtrace of fake generator frame
Fixes GH-15851
Closes GH-15952
2024-09-27 17:34:51 +02:00
Ilija Tovilo
756435a50c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix failed assertion when promoting Serialize deprecation to exception
2024-09-26 22:03:30 +02:00
Ilija Tovilo
5cff4a9b69 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix failed assertion when promoting Serialize deprecation to exception
2024-09-26 22:03:01 +02:00
Ilija Tovilo
15a0c3a9d4 Fix failed assertion when promoting Serialize deprecation to exception
Fixes GH-15907
Closes GH-15951
2024-09-26 22:01:59 +02:00
Niels Dossche
4b8a12d1e6 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16054: Segmentation fault when resizing hash table iterator list while adding
2024-09-25 21:08:36 +02:00
Ilija Tovilo
12844f96e2 Fix use-after-free of object released in hook
Fixes GH-16040
Closes GH-16058
2024-09-25 21:05:20 +02:00
Niels Dossche
fdd6ba62bb Fix GH-16054: Segmentation fault when resizing hash table iterator list while adding
zend_array_dup_ht_iterators() loops over the hash table iterators and
can call zend_hash_iterator_add(). zend_hash_iterator_add() can resize
the array causing a crash in zend_array_dup_ht_iterators().

We solve this by refetching the iter pointer after an add happened.

Closes GH-16060.
2024-09-25 21:05:05 +02:00
David Carlier
0d9f3a5600 Merge branch 'PHP-8.3' into PHP-8.4 2024-09-25 00:39:46 +01:00
David Carlier
4c03260261 Merge branch 'PHP-8.2' into PHP-8.3 2024-09-25 00:39:28 +01:00
David Carlier
5feb29ea03 Fix ubsan build on freebsd regarding float.
due to the system header machine/ieeefp.h proceeding to a bitshift
operation.

close GH-15935
2024-09-25 00:39:08 +01:00
Saki Takamachi
7225a11e59 update API/ABI versions 2024-09-25 00:44:02 +09: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
DanielEScherzer
ea297654f4 Zend/*: fix a bunch of typos (GH-16017)
* Zend/*: fix a bunch of typos

* Zend/tests/try/try_catch_finally_005.phpt: update string length
2024-09-24 10:55:21 +02:00
Arnaud Le Blanc
cc065bae3f Fix zend_lazy_object_get_properties for object with prop ht, when init fails (#15825)
zend_lazy_object_get_properties() is used by zend_std_get_properties_ex() to fetch the properties of lazy objects. It initializes the object and returns its properties.

When initialization fails we return an empty ht because most callers do not check for NULL. We rely on the exception thrown during initialization. We also assign that empty ht to zend_object.properties for the same reasons.

We asserted that zend_object.properties was either NULL or &zend_empty_array, but there are other cases in which a uninitialized lazy object may have a properties ht.

Here I remove the assertion, and return the existing properties ht if there is one. Otherwise I return zend_new_array(0) instead of &zend_emtpy_array as not all callers expect an immutable array (e.g. FE_FETCH does not).
2024-09-23 13:47:56 +02:00
DanielEScherzer
702fb31894 zend_resolve_const_class_name_reference(): use double quotes around names (#15998)
This is a follow-up to #15990, as it turns out there was a second place that emits this kind of error message.
2024-09-23 09:59:48 +01:00
DanielEScherzer
8e6d8cf1fa GH-15976: don't say "type alias" (#15996)
Follow-up to GH-15977
2024-09-23 09:59:12 +01:00
DanielEScherzer
34325c5e3a zend_assert_valid_class_name(): use double quotes around names (#15990) 2024-09-23 00:44:16 +01:00
DanielEScherzer
957feab461 [skip ci] Zend/tests/traits/trait_underscore_as_name.phpt: fix file name (#15991)
Accidentally called "enum_underscore_as_name.phpt"
2024-09-23 00:40:44 +01:00
Saki Takamachi
f6db576c31 [RFC] ext/bcmath: Added bcdivmod (#15740)
RFC: https://wiki.php.net/rfc/add_bcdivmod_to_bcmath

Added bcdivmod() function and added divmod() method to BcMath\Number class.
2024-09-23 06:43:11 +09:00
Daniel Scherzer
79d708cfca GH-15976: clarify error messages for enum/trait/interface/alias names
Instead of always saying that a name is reserved or deprecated and
cannot/should not be used as a class name, take the usage into account and say
the name cannot be used as an enum name, trait name, etc. In the process, for
class names add a missing "a".
2024-09-22 19:14:57 +01:00
Daniel Scherzer
ca679c681f GH-15976: test current output
So that it is clearer what changes
2024-09-22 19:14:57 +01:00
Michael Voříšek
d313ad6098 Deprecate E_STRICT constant and remove error level
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant

Closes GH-13053
2024-09-18 14:33:14 +02:00
Arnaud Le Blanc
17d46bb3b2 Fix oss-fuzz #71382 (#15854)
The return value of zho_build_properties_ex() is passed to ZVAL_ARR(), which sets the IS_TYPE_REFCOUNTED flag. Returning &zend_emtpy_array will crash later when trying to dtor the zval.

I'm fixing this by returning zend_new_array(0) instead of &zend_empty_array.

An alternative was to make ZVAL_ARR() aware of immutable arrays, like ZVAL_STR() is with interned strings, but I found no other problematic cases.
2024-09-17 16:06:51 +02:00
DanielEScherzer
21196ca9f6 zend_enum.c: make a bunch of pointers const (#15932)
* zend_enum.c: make a bunch of pointers `const`

* interface_gets_implemented needs non-constant

* zend_enum.h: update zend_verify_enum() signature
2024-09-17 12:57:01 +02:00
DanielEScherzer
a3583d7eef zend_inheritance.c: make a bunch of pointers const (GH-15934)
* zend_inheritance.c: make a bunch of pointers `const`

* Fix const double pointers
2024-09-17 12:44:17 +02:00
DanielEScherzer
65b4f22686 Fix some misleading comments about __clone() never being executed (#15926)
For the `Exception`, `ReflectionClass`, and `ReflectionAttribute` classes, the
`__clone()` method is declared to be private, and the implementation has a
comment that it should never be executed. However, the implementation can be
executed by using a `ReflectionMethod`. Fix the comments to instead explain why
the implementation is needed.

[skip ci]
2024-09-17 01:53:30 +02:00