Commit Graph

19304 Commits

Author SHA1 Message Date
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
Arnaud Le Blanc
c65e042c0b
Fix zend_get_property_info_for_slot() for lazy objects (#15855)
zend_get_property_info_for_slot(obj, slot) assumes that 'slot' belongs to 'obj', but that may not be the case for lazy proxies.

Fortunately, the property info is often already available in path when it is needed.

For other cases, I make zend_get_property_info_for_slot() aware of lazy objects, and add zend_get_property_info_for_slot_self() for cases where the 'slot' is known to belong to the object itself.

Fixes oss-fuzz #71446
2024-09-16 16:58:12 +02:00
Peter Kokot
888eb370cf
Fix -Wundef/C4668 warnings (#15853)
- ZTS is either undefined or defined (to 1)
- PHP_WIN32 is either undefined or defined (to 1)
- HAVE_LIBEDIT is either undefined or defined (to 1)
2024-09-14 11:28:32 +02:00
DanielEScherzer
3c8fd93dcf
[skip ci] zend_compile.h: ZEND_ACC_DEPRECATED can be used for class constants (#15848)
Support for deprecating class constants was added to implement the PHP 8.3
deprecations in #11615, but the documentation update was missed.

[skip ci]
2024-09-12 17:52:43 +01:00
David Carlier
81d580e334
Merge branch 'PHP-8.3' 2024-09-11 21:20:14 +01:00
David Carlier
eb460229ad
Merge branch 'PHP-8.2' into PHP-8.3 2024-09-11 21:19:58 +01:00
David Carlier
503d9145e0
Fix GH-15712: overflow on float print with precision ini large value.
When allocating enough room for floats, the allocator used overflows with
large ndigits/EG(precision) value which used an signed integer to
increase the size of thebuffer.
Testing with the zend operator directly is enough to trigger
the issue rather than higher level math interface.

close GH-15715
2024-09-11 21:19:07 +01:00
DanielEScherzer
db545767e5
Rename ZEND_STR_DEPRECATED to ZEND_STR_DEPRECATED_CAPITALIZED (#15831)
To match other capitalized strings like `ZEND_STR_UNKNOWN_CAPITALIZED` and
`ZEND_STR_ARRAY_CAPITALIZED`. Since this known string was only added in PHP
8.4, no backwards compatibility alias is needed.
2024-09-10 22:45:23 +01:00
Pierrick Charron
7e722e3ba4
PHP-8.2 is now for PHP 8.2.25-dev 2024-09-10 15:26:28 -04:00
Eric Mann
bb2b7df9dc
PHP-8.3 is now for PHP 8.3.13-dev 2024-09-10 06:38:48 -07:00
Dmitry Stogov
7c8b3b2c96
Fix GH-15821: Core dumped in Zend/Optimizer/zend_inference.c:4062 2024-09-10 16:14:03 +03:00
Ilija Tovilo
025ed70ce3
Fix ReflectionProperty::isInitialized() for hooked props
In zend_std_has_property with ZEND_PROPERTY_EXISTS, we'd just return true when
no get hook was present. However, this function is supposed to return false for
uninitialized properties. PROPERTY_EXISTS is somewhat of a misnomer. Virtual
properties continue to always return true, given there's no backing value to
check.

Fixes GH-15694
Closes GH-15822
2024-09-10 14:46:16 +02:00
Niels Dossche
f56a659293
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15661: Access null pointer in Zend/Optimizer/zend_inference.c
2024-09-09 20:12:07 +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
Ilija Tovilo
6ed730eb59
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix MSAN getservbyport() false positive
  Fix uninitialized CG(zend_lineno)
  Fix uninitialized EG(user_error_handler_error_reporting)
2024-09-09 19:35:09 +02:00
Ilija Tovilo
a5bd4ccb8c
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix MSAN getservbyport() false positive
  Fix uninitialized CG(zend_lineno)
  Fix uninitialized EG(user_error_handler_error_reporting)
2024-09-09 19:35:00 +02:00
Ilija Tovilo
1f35e2a999
Fix uninitialized CG(zend_lineno)
Closes GH-15813
2024-09-09 19:34:05 +02:00
Ilija Tovilo
b9fdc0bdcd
Fix uninitialized EG(user_error_handler_error_reporting)
Closes GH-15812
2024-09-09 19:33:32 +02:00
Ilija Tovilo
d5359ac7ce
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Intercept strlcpy and strlcat for msan on Clang 17 (#12674)
2024-09-09 16:45:54 +02:00
Ilija Tovilo
99504aa148
Intercept strlcpy and strlcat for msan on Clang 17 (#12674) 2024-09-09 16:45:46 +02:00
Ilija Tovilo
837a8b60bf
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix uninitialized lineno in constant AST of internal enums
2024-09-08 23:44:58 +02:00
Ilija Tovilo
e207071129
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix uninitialized lineno in constant AST of internal enums
2024-09-08 23:44:48 +02:00
Ilija Tovilo
08e0729c57
Fix uninitialized lineno in constant AST of internal enums
Closes GH-15806
2024-09-08 23:44:11 +02:00
Christoph M. Becker
50b3a0d011
Add comments about internal headers (GH-15689)
A common convention is to name internal C header files as `*_int.h`.
Since a couple of these are actually installed, we add comments that
this is not supposed to happen, (a) to avoid installing further
internal headers, and (b) to pave the way to fix this in the next major
PHP version.

Somewhat special is php_gmp_int.h, where "int" is meant as abbreviation
for "interface".

Another common convention is appending `_priv` or `_private`, but since
there have not been any issues regarding these headers so far, we
refrain from adding respective comments to these headers.

Anyhow, it might be a good idea to introduce some common naming
convention for such internal/private headers.
2024-09-08 16:11:25 +02:00
Peter Kokot
e358634cdc
Sync Zend/*_i386_sysv_elf_gas.S with upstream (#15788)
This is a sync with upstream already fixed in early 2024 which fixes
64-bit builds on 32-bit hosts. PHP's bundled config.guess sets the
host_alias, for example, on Solaris systems to 64-bit if the compiler
supports it even though the architecture is actually 32-bit. These
assembly files resolve this situation in a build-system-agnostic way by
including the architecture file that is supported by the compiler.
2024-09-07 21:27:02 +02:00
Peter Kokot
de48b90d61
Convert CRLF line endings to LF (#15767)
This patch simplifies line endings tracked in the Git repository and
syncs them to the LF style instead of the CRLF.

Newline characters:
- LF (\n) (*nix and Mac)
- CRLF (\r\n) (Windows)
- CR (\r) (old Mac, obsolete)

To see which line endings are in the index and in the working copy the
following command can be used:
`git ls-files --eol`

Git also provides `.gitattributes` file to specify files that need
specific line endings in the working directory on all platforms (either
CRLF or LF):

```
file-with-crlf text eol=crlf
```

Changed files shouldn't cause issues on modern Windows platforms because
also Git can do output conversion if core.autocrlf=true is set on
Windows and use CRLF newlines in all files in the working tree.

Unless CRLF files are tracked specifically, Git by default tracks all
files in the index using LF newlines.
2024-09-07 11:03:32 +02:00
DanielEScherzer
047f0c9657
userland_declaration_error_class_const.phpt: fix test name (#15784)
Unlike the `userland_declaration_error_const.phpt` test, the point of this test
is to demonstrate using a class constant as the default parameter. See also the
corresponding internal_declaration_* tests.

[skip ci]
2024-09-07 07:37:05 +02:00
Bob Weinand
25d761623c
Make internal run_time_cache a persistent allocation (#15040)
We also add zend_map_ptr_static, so that we do not incur the overhead of constantly recreating the internal run_time_cache pointers on each request.
This mechanism might be extended for mutable_data of internal classes too.
2024-09-07 01:45:26 +02:00
Peter Kokot
824f55ae84
Sync Zend/asm/make_ppc64_sysv_macho_gas.S with upstream (#15769)
There was a typo in make_ppc64_sysv_macho_gas.S with missing closing
multi-line comment. Upstream fixed it in ~2023:
https://github.com/boostorg/context/
2024-09-06 08:42:44 +02:00
DanielEScherzer
f17c220388
[skip ci] Zend/tests/return_types/never_generator.phpt: fix test name (GH-15757)
The test is unrelated to parameter types, likely left over from a copy-paste
with never_parameter.phpt
2024-09-05 19:26:26 +02:00
DanielEScherzer
e1f7197f89
[skip ci] zend_compile.h: ZEND_ACC_FINAL can be used for constants (GH-15764)
There was a whole RFC about this, but the implementation in #6878 seems to have
missed updating the documentation
2024-09-05 19:22:07 +02:00
DanielEScherzer
5a18279b5d
Fix GH-15731: Prevent #[AllowDynamicProperties] on enums (#15733) 2024-09-04 23:56:18 +01:00
Levi Morrison
6435bb5ae1
Interrupt while internal frame is on the stack (#14627)
* Check VM interrupt while internal frame is on top

* Use tab instead of spaces

* fix frame used in interrupt and refactor

* remove unused failures for zend_jit_check_timeout

* Fix JIT support

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>

* Fix the missing store to vm_interrupt

* Rename new functions

* Special case zend_interrupt_function in JIT code

* refactor to use ZEND_VM_SET_OPCODE_NO_INTERRUPT

* Split atomic exchange into load + store

It is difficult to determine performance of atomics sometimes. In this
case, the separate load+store is still correct, and a load does not
cause a modification, and might be faster for some platforms than an
exchange. A load+store is slower than an exchange, but we're fine
trading the penalty to the slow path and keeping the happy path faster.

---------

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
2024-09-05 00:35:55 +02:00
DanielEScherzer
f9d01e46fe
#[AllowDynamicProperties] validation: improve error messages (#15734)
For traits and interfaces, include the name of the relevant trait (or
interface) in the error message, the same way it is included for readonly
classes.
2024-09-04 22:54:42 +02:00
DanielEScherzer
d552fbd9f7
zend_get_constant_ex() - remove commented out handling of class constants (#15728)
Was factored out into a dedicated method, `zend_get_class_constant_ex()`, back
in 2021 (4dcde9cf18) but instead of removing the
old logic it was just commented out. If it hasn't been needed since 2021, it
should be safe to remove.
2024-09-04 16:15:27 +02:00
DanielEScherzer
5dd0575698
Generated arginfo header files: combine preprocessor conditional blocks (#15736)
When functions' or class methods' availability is based on some preprocessor
condition, the generated arginfo header files wrap the declarations in the
preprocessor `#if` conditional blocks, one per declaration, even if they are in
the same conditional block based on comments in the stub file. Instead of
having multiple conditional blocks one after the other with the same condition,
combine them into a single conditional block.
2024-09-04 13:04:22 +02:00
DanielEScherzer
53cb89670c
Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
2024-09-03 23:19:53 +02:00
Ilija Tovilo
7f0d2574f0
Simplify a-vis error message 2024-09-03 12:18:07 +02:00
Christoph M. Becker
6d5962074f
Dynamically xfail test cases which fail on CI (GH-15710)
This is a stop-gap measure for GH-15709 to keep CI green.
2024-09-02 18:23:52 +02:00
Ilija Tovilo
2b8a1b4258
Forbid a-vis on unilateral virtual prop
The get-only case is obvious, there is no set operation so specifying its
visibility is senseless. The set-only case is also questionable, since there is
no operation other than set, so changing the visibility of the entire property
is preferable.

Closes GH-15698
2024-09-02 17:40:30 +02:00
Niels Dossche
5ca4d8828d
Remove redundant 'zobj->ce->__isset' check (#15699)
This became unnecessary due to the addition of lazy objects that added
the goto when '!zobj->ce->__isset' above.
2024-09-01 23:10:54 +02:00
Jorg Adam Sowa
2a30f2ffc4
Add type indicator to array/arg unpack error messages (GH-15448) 2024-09-01 22:57:12 +02:00
Christoph M. Becker
0b1e401f2c
Skip tests calling wmic if it is not available
The WMIC utitlity is deprecated as of Windows 10 21H1, and a feature on
demand which is enabled by default in Windows 11 22H2 and 23H2, but
will be disabled by default in the next release of Windows.[1]

Therefore, we ensure that tests which rely on wmic.exe are properly
skipped if it is not available.

[1] <https://learn.microsoft.com/en-us/windows/whats-new/deprecated-features#deprecated-features>

Closes GH-15583.
2024-09-01 17:19:37 +02:00
Arnaud Le Blanc
58aa6fc830
Lazy objects
RFC: https://wiki.php.net/rfc/lazy-objects

Closes GH-15019
2024-08-30 17:30:03 +02:00
Ilija Tovilo
e12188fe89
Fix asymmetric visibility with set hook
Fixes GH-15644
Closes GH-15645
2024-08-30 09:42:27 +02:00