1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Commit Graph

19577 Commits

Author SHA1 Message Date
Jorg Adam Sowa
ac2ce94de0 zend_hrtime: Fix build for macOS without clock_gettime_nsec_np() (#17437) 2025-01-16 18:57:51 +01:00
Christoph M. Becker
6967de563e Simplify ZEND_SIGNED_MULTIPLY_LONG() on Windows (GH-17477)
For Clang, we just need to define the respective macros, since these
built-ins are available in all supported Clang versions (>= 4.0.0,
currently)[1].

For MSVC (and possibly other compilers) we use the respective APIs of
intsafe.h[2] which are available as of Windows 7/Server 2008 R2.

For x86 (and to a lesser extend for ARM64) that should also notably
improve performance.

[1] <https://releases.llvm.org/4.0.0/tools/clang/docs/LanguageExtensions.html>
[2] <https://learn.microsoft.com/en-us/windows/win32/api/intsafe/>
2025-01-16 13:57:07 +01:00
Christoph M. Becker
7512685767 Use built-ins for addition and subtraction on Windows (GH-17472)
For Clang, we just need to define the respective macros, since these
built-ins are available in all supported Clang versions (>= 4.0.0,
currently)[1].

For MSVC (and possibly other compilers) we use the respective APIs of
intsafe.h[2] which are available as of Windows 7/Server 2008 R2.

This avoids the UB due to signed integer overflow that may happen with
our fallback implementations.

We also drop the superfluous SHORT_MAX definition from pdo_firebird.
This shouldn't be defined unconditionally, but since it is apparently
unused, we remove it altogether.

[1] <https://releases.llvm.org/4.0.0/tools/clang/docs/LanguageExtensions.html>
[2] <https://learn.microsoft.com/en-us/windows/win32/api/intsafe/>
2025-01-15 12:58:12 +01:00
Ilija Tovilo
e95b298262 Store prop info name in CG(context) instead of prop info
The prop info is not always available, e.g. when compiling the default
value.

See GH-17378
Closes GH-17464
2025-01-14 17:01:10 +01:00
Ilija Tovilo
0e1fbf97f4 Merge branch 'PHP-8.4'
* PHP-8.4:
  Relax final+private warning for trait methods with inherited final
2025-01-13 16:46:54 +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
a06668af30 Merge branch 'PHP-8.4'
* PHP-8.4:
  __PROPERTY__ does not work in all constant expression contexts
2025-01-13 16:43:32 +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
Christoph M. Becker
1675d32261 Fix printf style issues in Windows specific code (GH-17452)
A couple of calls pass strings as formats (`-Wformat-security`), and
some others mix up types (`-Wformat`).
2025-01-13 11:50:05 +01:00
Tim Düsterhus
d8d1cb4195 zend_ast: Print placeholder value when printing ZEND_AST_OP_ARRAY (#17405)
As per the discussion in GH-17120, we are printing a placeholder value only.
The commit history of that PR also includes alternative implementations, should
a different decision be desirable.

Fixes GH-17096
Closes GH-17120
2025-01-10 08:37:17 +01:00
Niels Dossche
5d4707e22a Merge branch 'PHP-8.4'
* PHP-8.4:
  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:52 +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
Tim Düsterhus
e421a44ac6 zend_ast: Remove unused ZEND_AST_EXIT (#17417)
This AST node is no longer used since `exit()` was made a real function in
GH-13483.
2025-01-09 12:23:33 +01:00
Tim Düsterhus
cee64ed3bd Add dedicated zend_ast_op_array struct (#17391)
Given that the `ZEND_AST_OP_ARRAY` type already needed special handling in
various places, it makes sense to give it its own struct to avoid some of the
casts. As a side benefit, it is a little smaller than the `zend_ast_zval`
struct.
2025-01-08 11:26:35 +01:00
Tim Düsterhus
fd1eacc2ed Add assertions verifying that zend_ast_decl AST nodes are not treated as regular zend_ast nodes (#17390)
* zend_compile: Do not traverse children of ZEND_AST_CLOSURE in zend_compile_const_expr()

* Add assertions verifying that zend_ast_decl AST nodes are not treated as regular zend_ast nodes
2025-01-08 10:36:02 +01:00
Niels Dossche
cc4402b6cb Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17234: Numeric parent hook call fails with assertion
2025-01-07 19:21:35 +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
Gina Peter Banyard
e40543a401 zend_closures.c: In Closure::__invoke() call the closure directly (#17372)
This prevents a bunch of indirection which ultimately calls `zend_closure_get_closure()` anyway via the `get_closure` object handler.
2025-01-07 09:20:36 +00:00
Eric Norris
d20880ce3b RFC: Add CurlSharePersistentHandle objects (#16937)
see https://wiki.php.net/rfc/curl_share_persistence_improvement
2025-01-06 21:52:00 +01:00
Máté Kocsis
684ef016e1 Add support for using final properties in stubs (#17306) 2025-01-06 07:56:13 +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
ecb90c1db7 Remove incorrect RC1 annotation for get_include_path() (#17301)
This annotation is wrong since GH-17294.
2024-12-30 14:38:30 +01:00
Niels Dossche
55afe8bd9b Implement GH-15680: Enhance zend_dump_op_array to Properly Represent Non-Printable Characters in String Literals
Replaces GH-15730 as that PR became stale.

But instead of introducing a new helper, reuse
smart_str_append_escaped(), this also removes the dependency on
ext/standard.

Closes GH-15730.
Closes GH-17277.
2024-12-27 12:53:02 +01:00
Niels Dossche
afc1f0d99b Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17216: Trampoline crash on error
2024-12-21 00:26:37 +01: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
420365d922 Merge branch 'PHP-8.4'
* PHP-8.4:
  Add observer temporary to dl'ed functions
2024-12-20 18:52:43 +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
Ilija Tovilo
8aac6987c2 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix RC inference of op1 of FETCH_OBJ and INIT_METHOD_CALL
  Add tests for GH-17151
2024-12-18 19:10:00 +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
e69317b501 Reduce gc stack usage for strings (and resources)
Adding strings to the worklist is useless, because they never contribute to
cycles. The assembly size on x86_64 does not change. This significantly improves
performance in this synthetic benchmark by 33%.

    function test($a) {}

    $a = new stdClass();
    $a->self = $a;
    $a->prop1 = str_repeat('a', 10);
    $a->prop2 = str_repeat('a', 10);
    $a->prop3 = str_repeat('a', 10);
    $a->prop4 = str_repeat('a', 10);
    $a->prop5 = str_repeat('a', 10);
    $a->prop6 = str_repeat('a', 10);
    $a->prop7 = str_repeat('a', 10);
    $a->prop8 = str_repeat('a', 10);
    $a->prop9 = str_repeat('a', 10);
    $a->prop10 = str_repeat('a', 10);

    for ($i = 0; $i < 10_000_000; $i++) {
        test($a);
        gc_collect_cycles();
    }

This requires adding IS_TYPE_COLLECTABLE to IS_REFERENCE_EX to ensure these
values continue to be pushed onto the stack. Luckily, IS_TYPE_COLLECTABLE is
currently only used in gc_check_possible_root(), where the checked value cannot
be a reference.

Note that this changes the output of gc_collect_cycles(). Non-cyclic, refcounted
values no longer count towards the total reported values collected.

Also, there is some obvious overlap with GH-17130. This change should be good
nonetheless, especially if we can remove the GC_COLLECTABLE(Z_COUNTED_P(zv))
condition in PHP 9 and rely on Z_COLLECTABLE_P() exclusively, given we can
assume an object doesn't become cyclic at runtime anymore.

Closes GH-17194
2024-12-18 18:58:41 +01:00
Ilija Tovilo
287aeebba7 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix incorrect dynamic prop offset in hooked prop iterator
2024-12-18 18:48:01 +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
97f44b7c39 Merge branch 'PHP-8.4'
* PHP-8.4:
  Export visibility for promoted property (8.3)
  [ci skip] News for GH-17101
  Add test for GH-17101
  Print hooks in parameter exports
  Fix property hook name mismatch
  Extract hook export code
  Export visibility for promoted property
2024-12-17 19:14:55 +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
1371f50daa Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17162: zend_array_try_init() with dtor can cause engine UAF
2024-12-15 20:12:17 +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