1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Commit Graph

19621 Commits

Author SHA1 Message Date
Calvin Buckley
3e1a564f92 Update versions for PHP 8.4.13 2025-09-23 11:14:07 -03:00
Niels Dossche
c58312462c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19720: Assertion failure when error handler throws when accessing a deprecated constant
2025-09-06 00:01:13 +02:00
Niels Dossche
9d69ab91ab Fix GH-19720: Assertion failure when error handler throws when accessing a deprecated constant
When deprecation causes an exception, we should return NULL instead of
continuing.

Closes GH-19723.
2025-09-06 00:00:52 +02:00
Arnaud Le Blanc
d68fd7390d Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Ensure that type widening converges
2025-09-04 09:14:31 +02:00
Arnaud Le Blanc
bd88a54934 Ensure that type widening converges
Range analysis may fail to converge (the process hangs) when the transfer
function zend_inference_calc_range produces a smaller range.

Fix by ensuring that the widening operator zend_inference_widening_meet
allows only widening. This matches the inference rules in figure 13 of the
paper.

Fixes GH-19679
Closes GH-19683
2025-09-04 08:58:06 +02:00
Ilija Tovilo
e4c94829a2 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Stale array iterator pointer
2025-09-03 18:15:35 +02:00
Ilija Tovilo
f9ce6d8f3a Stale array iterator pointer
Fixes GH-19613
Closes GH-19616
2025-09-03 18:14:43 +02:00
Arnaud Le Blanc
62e30ecae1 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Differenciate WeakMaps from bare HashTables used as weak maps for GC purposes
2025-08-22 16:33:08 +02:00
Arnaud Le Blanc
d74901ae1a Differenciate WeakMaps from bare HashTables used as weak maps for GC purposes
Since cbf67e4, the GC needs to find all WeakMaps referencing a weakly
referenced object. Doing so, it treats all ZEND_WEAKREF_TAG_MAP as WeakMap
instances.

However, a ZEND_WEAKREF_TAG_MAP reference may be a bare HashTable when
zend_weakrefs_hash_add() is used.

Introduce a new tag, ZEND_WEAKREF_TAG_BARE_HT, and use this tag when weakly
referencing an object from a bare HashTable. Ignore such references in GC.

Fixes GH-19543
Closes GH-19544

Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-08-22 16:32:30 +02:00
Ilija Tovilo
7f9809c438 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix signed int overflow in scanner
2025-08-22 16:26:30 +02:00
Ilija Tovilo
0a12aaa5b8 Fix signed int overflow in scanner
yylen is unsigned int, but len in zend_scan_escape_string() is int, which will
break for string literals >=2GB. yyleng is still limited to 4GB, but we can't
fix this without breaking the ABI.

Partially addresses GH-19542
Closes GH-19545
2025-08-22 16:24:20 +02:00
Ilija Tovilo
708d8e9cfd Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix "Constant already defined" warning with repeated inclusion of file with __halt_compiler()
2025-08-14 12:15:00 +02:00
Ilija Tovilo
a3de2ce9ba Fix "Constant already defined" warning with repeated inclusion of file with __halt_compiler()
Fixes GH-18850
Closes GH-19471
2025-08-14 12:13:50 +02:00
Eric Mann
a0bd2c9fcf PHP-8.3 is now for PHP 8.3.26-dev 2025-08-12 08:15:40 -07:00
Saki Takamachi
b7c26eb16c PHP-8.4 is now for PHP 8.4.13-dev 2025-08-12 23:46:26 +09:00
Niels Dossche
8b5231388c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19065: Long match statement can segfault compiler during recursive SSA renaming
2025-08-11 23:05:50 +02:00
Niels Dossche
9b86533ce4 Fix GH-19065: Long match statement can segfault compiler during recursive SSA renaming
On some systems, like Alpine, the thread stack size is small by default.
The last step of SSA construction involves variable renaming that is
recursive, and also makes copies of their version of the renamed
variables on the stack. This combination causes a stack overflow during
compilation on Alpine. Triggerable for example with very long match
statements.

A stop-gap solution would be to use heap allocated arrays for the
renamed variable list, but that would only delay the error as increasing
the number of match arms increases the depth of the dominator tree, and
will eventually run into the same issue.

This patch transforms the algorithm into an iterative one.
There are two states stored in a worklist stack: positive numbers
indicate that the block still needs to undergo variable renaming.
Negative numbers indicate that the block and its dominated children are
already renamed. Because 0 is also a valid block number, we bias the
block numbers by adding 1.
To restore to the right variant when backtracking the "recursive" step,
we index into an array pointing to the different variable renaming
variants.

Closes GH-19083.
2025-08-11 23:05:21 +02:00
David Carlier
bd2766ce79 zend call stack fixing stack limit for macOs arm64.
8MB sounded a prudent size for older 10.9 macOs release, however
with newer mac with arm64, it triggers a stack overflow.

Cherry picks b320aabc5e (GH-13319) from PHP-8.4.
Closes GH-19390.
2025-08-07 08:38:40 +02:00
Ilija Tovilo
b3f4863373 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix circumvented type check with return by ref + finally
2025-08-01 00:36:28 +02:00
Ilija Tovilo
d0fad34230 Fix circumvented type check with return by ref + finally
Fixes GH-18736
Closes GH-19172
2025-08-01 00:35:48 +02:00
Ilija Tovilo
5d40592fe2 Fix stale nInternalPosition on rehashing
Since GH-13188 we're no longer immediately updating iterator positions when
deleting array elements. zend_hash_rehash() needs to adapt accordingly by
adjusting nInternalPosition for IS_UNDEF elements. This is already the case for
array iterators.

Fixes GH-19280
Closes GH-19323
2025-07-31 21:55:08 +02:00
Arnaud Le Blanc
781d77ac54 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Prevent throwing in running generator
2025-07-31 14:29:01 +02:00
Arnaud Le Blanc
6fa8a25a40 Prevent throwing in running generator
Generator::throw() on a running generator is not allowed. It throws "Cannot
resume an already running generator" when trying to resume the generator to
handle the provided exception.

However, when calling Generator::throw() on a generator with a non-Generator
delegate, we release the delegate regardless. If a Fiber was suspended in
the delegate, this causes use after frees when the Fiber is resumed.

Fix this by throwing "Cannot resume an already running generator" earlier.

Fixes GH-19326
Closes GH-19327
2025-07-31 14:26:41 +02:00
Arnaud Le Blanc
a430ee2dd2 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Prevent resumption of generator suspended in yield from
2025-07-31 08:46:06 +02:00
Arnaud Le Blanc
0406a55c92 Prevent resumption of generator suspended in yield from
Normally we prevent generators from being resumed while they are already
running, but we failed to do so for generators delegating to non-Generators. As
a result such generator can be resumed, terminated, which causes unexpected
results (crashes) later.

In gh19306.phpt in particular, the generator delegate It::getIterator() suspends
while being called by generator g(). We then resume g(), which throws while
trying to resume It::getIterator(). This causes g() and It::getIterator()
to be released. We then UAF when resuming the Fiber in It::getIterator().

Fix this by ensuring that generators are marked as running while they fetch
the next value from the delegate.

Fixes GH-19306
Closes GH-19315
2025-07-31 08:45:19 +02:00
Niels Dossche
a08df32f18 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19303: Unpacking empty packed array into uninitialized array causes assertion failure
2025-07-30 22:48:59 +02:00
Niels Dossche
5bd5f352e5 Fix GH-19303: Unpacking empty packed array into uninitialized array causes assertion failure
Having an empty result array is not a problem, because zend_hash_extend()
will initialize it. Except it does not when the number of elements to add
equals 0, which leaves the array uninitialized and therefore does not
set the packed flag, causing the assertion failure.

Technically, removing the assert would also work and save a check.
On the other hand, this check could also prevent some real work to be
done and should be relatively cheap as we already have to compute the
sum anyway.

Closes GH-19318.
2025-07-30 22:47:11 +02:00
Arnaud Le Blanc
28ed4e6ec0 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Prevent operands from being released during comparison
2025-07-30 18:11:32 +02:00
Arnaud Le Blanc
bc4b6ce7a8 Prevent operands from being released during comparison
Fixes GH-19305
Closes GH-19309
2025-07-30 18:09:24 +02:00
Ilija Tovilo
138ebf481b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix failed assertion with throwing __toString in binary const expr
2025-07-30 13:34:32 +02:00
Ilija Tovilo
80022c035b Fix failed assertion with throwing __toString in binary const expr
Solve this with the same pattern as ZEND_AST_GREATER[_EQUAL].

Fixes OSS-Fuzz #434346548
Closes GH-19291
2025-07-30 13:34:01 +02:00
Ilija Tovilo
4bc5aa3531 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Coerce numeric string keys from iterators when argument unpacking
2025-07-22 17:47:56 +02:00
Ilija Tovilo
23ec35bf4a Coerce numeric string keys from iterators when argument unpacking
Fixes GH-18581
Closes GH-19151
2025-07-22 17:46:34 +02:00
Bob Weinand
b13347be38 Fix GH-19044: Protected properties are not scoped according to their prototype (#19046)
* Fix GH-19044: Protected properties are not scoped according to their prototype

* Adjust after review

* Simplify to using prototype even for asymmetric visibility
2025-07-22 17:46:14 +02:00
Niels Dossche
c04f2d2d88 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add missing cc clobber
2025-07-22 12:43:21 +02:00
Niels Dossche
13c781f04d Add missing cc clobber
Closes GH-19205.
2025-07-22 12:43:08 +02:00
Ilija Tovilo
c8cc23336d Fix properties_info_table for abstract properties
Fixes GH-19053
Closes GH-19140

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
2025-07-21 15:54:24 +02:00
David Carlier
f1a77c0198 Merge branch 'PHP-8.3' into PHP-8.4 2025-07-18 18:02:02 +01:00
Petr Sumbera
be09985c87 Fix GH-19169: ZEND_STATIC_ASSERT for -std=c++17
needs to define ZEND_STATIC_ASSERT to appropriate C++ static_assert
instead of the C version.
2025-07-18 18:00:24 +01:00
Jakub Zelenka
faf833bffc PHP 8.3 is now for PHP-8.3.25-dev 2025-07-16 14:09:24 +02:00
Calvin Buckley
3d468a181a PHP-8.4 is now for PHP 8.4.12-dev 2025-07-15 13:46:33 -03:00
Demon
2be3aa86f0 Zend: fix undefined symbol 'execute_ex' on Windows ARM64 #19064; ext/gd: fix emmintrin.h not found on Windows ARM64 2025-07-10 22:13:29 +02:00
Peter Kokot
ab6e73066b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix -Wuseless-escape warnings emitted by re2c (#19050)
2025-07-07 09:51:50 +02:00
Peter Kokot
258fbd6bf9 Fix -Wuseless-escape warnings emitted by re2c (#19050)
re2c version 4 enabled some warnings by default. This fixes re2c code
for the `-Wuseless-escape` warnings.

There are two same issues reported.
Issue: GH-17523
Closes: GH-17204
2025-07-07 09:51:25 +02:00
Niels Dossche
1af7d8e547 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix OSS-Fuzz #428983568 and #428760800
2025-07-04 23:58:33 +02:00
Niels Dossche
4aac98f145 Fix OSS-Fuzz #428983568 and #428760800
Both these issues have the same root cause, their reproducer is
extremely similar so I don't duplicate the test.

If the parser invokes the lexer, and the lexer fails, it could've
allocated a string which must be freed when the parser backs up.
The `%destructor` list is responsible for this but did not have an entry
for `fallback` yet. Solve the issue by adding such an entry.

Closes GH-19012.
2025-07-04 23:58:06 +02:00
Saki Takamachi
d5fe1bce63 PHP-8.4 is now for PHP 8.4.11-dev 2025-07-02 11:39:33 +09:00
Niels Dossche
5d590a1e87 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix OSS-Fuzz #427814456
2025-07-01 18:52:39 +02:00
Niels Dossche
91749844e6 Fix OSS-Fuzz #427814456
The first warning may trigger an error handler, destroying the operand
and its string. So we need to protect the string in that case.
Care was taken to avoid unnecessary refcounts and to avoid touching the
hot code path.

Closes GH-18951.
2025-07-01 18:50:41 +02:00
Shivam Mathur
a8bd3ba1bb Merge branch 'PHP-8.3' into PHP-8.4 2025-06-25 03:22:43 +05:30