Commit Graph

2803 Commits

Author SHA1 Message Date
Máté Kocsis
b06c95b631
Declare the missing true return types (#13709) 2024-03-16 07:26:37 +01:00
Máté Kocsis
577db99462
Verify stub aliases in CI (#13682)
In the same time, let's not verify implementation aliases since they may now legitimately differ from their aliased function/method counterparts (think about the ext/dom refactoring where e.g. many return type declarations have changed). Additionally, unnecessary `@no-verify` tags are cleaned up.
2024-03-13 23:32:35 +01:00
Máté Kocsis
330cc5cdb2
Deprecate implicit nullable parameter types (#12959)
RFC: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types

Co-authored-by: Gina Peter Banyard <girgias@php.net>
2024-03-13 21:40:26 +01:00
Gina Peter Banyard
0de88dfb81
ext/spl: mark all zend_object_handlers as static (#13547) 2024-02-28 15:31:28 +00:00
Niels Dossche
1d20fc5fc5 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-13531: Unable to resize SplfixedArray after being unserialized in PHP 8.2.15
2024-02-27 23:05:34 +01:00
Niels Dossche
0285395126 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13531: Unable to resize SplfixedArray after being unserialized in PHP 8.2.15
2024-02-27 23:05:26 +01:00
Niels Dossche
8494058a1f Fix GH-13531: Unable to resize SplfixedArray after being unserialized in PHP 8.2.15
When unserializing, the cached_resize field was not reset to -1
correctly, causing the setSize() method to think we were inside of a
resize operation.

Closes GH-13543.
2024-02-27 23:04:23 +01:00
Máté Kocsis
f2e199e878
Implement "support doc comments for internal classes and functions" (#13266)
Fixes #13130
2024-02-25 08:41:31 +01:00
Máté Kocsis
10957e498c
Do not generate frameless info items when func info generation is disabled
While here, I fixed newlines around arginfo and function entry generation. Previously, newlines were repeated.
2024-02-18 11:39:00 +01:00
Gina Peter Banyard
f7b498b02e
Use true as return types for SplHeap (#13147) 2024-01-15 10:09:38 +00:00
David CARLIER
9726721560
general signatures discrepencies fixes (#13122) 2024-01-10 22:19:23 +00:00
Niels Dossche
642e11140c
Minor pcre optimizations (#12923)
* Update signature of pcre API

This changes the variables that are bools to actually be bools instead
of ints, which allows some additional optimization by the compiler (e.g.
removing some ternaries and move extensions).

It also gets rid of the use_flags argument because that's just the same
as flags == 0. This reduces the call frame.

* Use zend_string_release_ex where possible

* Remove duplicate symbols from strchr

* Avoid useless value conversions

* Use a raw HashTable* instead of a zval

* Move condition

* Make for loop cheaper by reusing a recently used value as start iteration index

* Remove useless condition

This can't be true if the second condition is true because it would
require the string to occupy the entire address space.

* Upgrading + remark
2023-12-11 19:43:26 +01:00
Niels Dossche
f283f50f1a Merge branch 'PHP-8.3'
* PHP-8.3:
  Add missing NULL checks for spl autoload table
  Add missing NULL pointer checks related to the previous call frame
2023-12-01 09:11:32 +01:00
Niels Dossche
0e69329bb0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add missing NULL checks for spl autoload table
  Add missing NULL pointer checks related to the previous call frame
2023-12-01 09:09:58 +01:00
Niels Dossche
9a69bb2d58 Add missing NULL checks for spl autoload table
Closes GH-12840.
2023-12-01 09:09:17 +01:00
Niels Dossche
a963b1fbd9 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-12721: SplFileInfo::getFilename() segfault in combination with GlobIterator and no directory separator
2023-11-19 11:53:21 +01:00
Niels Dossche
0a3b891ba1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-12721: SplFileInfo::getFilename() segfault in combination with GlobIterator and no directory separator
2023-11-19 11:52:58 +01:00
Niels Dossche
4d41dffb4f Fix GH-12721: SplFileInfo::getFilename() segfault in combination with GlobIterator and no directory separator
This broke in 7cd8879 and 9bae9ab. NULL is a perfectly valid return
value that should be handled.

Closes GH-12722.
2023-11-19 11:52:27 +01:00
George Peter Banyard
ba204a2e3a
ext/spl: Restructure spl_array.c file to move ArrayObject methods together 2023-11-16 00:41:37 +00:00
Niels Dossche
4cfc8f6d7a
Remove dead stores from ext/spl (#12550) 2023-10-29 14:42:23 +00:00
Ilija Tovilo
f39b5c4c25
Close PHP tags in tests
Closes GH-12422
2023-10-18 17:34:10 +02:00
George Peter Banyard
e41598c7fc ext/spl: Use new F ZPP modifier 2023-10-10 13:44:21 +01:00
Niels Dossche
009d48da1c
Convert bounds exception in SplFixedArray to OutOfBoundsException instead of RuntimeException (#12383) 2023-10-08 18:57:57 +02:00
Jorg Adam Sowa
f0757100a4
Typed constants in SPL extension (#12358) 2023-10-07 13:14:57 +01:00
Niels Dossche
dc72ceda90 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-11972: RecursiveCallbackFilterIterator regression in 8.1.18
2023-08-30 22:27:06 +02:00
Niels Dossche
262a22740c Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11972: RecursiveCallbackFilterIterator regression in 8.1.18
2023-08-30 22:26:36 +02:00
Niels Dossche
ffd7018fcd Fix GH-11972: RecursiveCallbackFilterIterator regression in 8.1.18
When you do an assignment between two zvals (no, not zval*), you copy
all fields. This includes the additional u2 data. So that means for
example the Z_NEXT index gets copied, which in some cases can therefore
cause a cycle in zend_hash lookups.
Instead of doing an assignment, we should be doing a ZVAL_COPY (or
ZVAL_COPY_VALUE for non-refcounting cases). This avoids copying u2.

Closes GH-12086.
2023-08-30 22:18:33 +02:00
Niels Dossche
63a7f225ea Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix #81992: SplFixedArray::setSize() causes use-after-free
2023-08-14 21:38:36 +02:00
Niels Dossche
0b516aea25 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix #81992: SplFixedArray::setSize() causes use-after-free
2023-08-14 21:34:04 +02:00
Niels Dossche
b71c6b2c6c Fix #81992: SplFixedArray::setSize() causes use-after-free
Upon resizing, the elements are destroyed from lower index to higher
index. When an element refers to an object with a destructor, it can
refer to a lower (i.e. already destroyed) element, causing a uaf.
Set refcounted zvals to NULL after destroying them to avoid a uaf.

Closes GH-11959.
2023-08-14 21:32:22 +02:00
Ilija Tovilo
ee000ea186
Fix uouv on oom on object allocation
We may OOM during object initialization. In this case, free_obj needs to guard
against NULL values. There may be more cases where this is an issue, these were
the ones I was able to discover via script.

Fixes GH-11734
2023-08-14 11:10:00 +02:00
Niels Dossche
0b2e6bc2b0 Cache d_type in directory entry 2023-07-07 18:02:32 +02:00
Niels Dossche
1fbbd2b250 Remove unused is_recursive entry
This only takes up space and time.
2023-07-07 18:02:17 +02:00
Ilija Tovilo
7b355e8d34
Revert "Merge branch 'PHP-8.2'"
This reverts commit 45a3f178dc, reversing
changes made to b2a54bc6af.
2023-07-04 09:18:49 +02:00
Máté Kocsis
45a3f178dc
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-9967 Add support for generating custom function, class const, and property attributes in stubs

Closes GH-10170
2023-07-03 11:17:08 +02:00
George Peter Banyard
d5ad75108e
More usage of known zend_str instead of C string (#11381) 2023-06-08 13:03:29 +01:00
George Peter Banyard
99fa740acb
Use common function for TypeError on illegal offset access (#10544)
This merges all usages of emitting an offset TypeError into a new ZEND_API function
zend_illegal_container_offset(const zend_string* container, const zval *offset, int type);

Where the container should represent the type on which the access is attempted (e.g. string, array)
The offset zval that is used, where the error message will display its type
The type of access, which should be a BP_VAR_* constant, to get special message for isset/empty/unset
2023-06-06 11:28:19 +01:00
Niels Dossche
5fae4b5031 Struct-pack spl_dllist_object 2023-06-04 13:52:55 +01:00
nielsdos
1ed68686de Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix DOMElement::append() and DOMElement::prepend() hierarchy checks
  Fix spec compliance error for DOMDocument::getElementsByTagNameNS
  Fix GH-11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked
  Fix GH-11338: SplFileInfo empty getBasename with more than one slash
2023-05-30 17:41:54 +02:00
nielsdos
0e7ad40900 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix DOMElement::append() and DOMElement::prepend() hierarchy checks
  Fix spec compliance error for DOMDocument::getElementsByTagNameNS
  Fix GH-11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked
  Fix GH-11338: SplFileInfo empty getBasename with more than one slash
2023-05-30 17:38:18 +02:00
Niels Dossche
bce536067c Fix GH-11338: SplFileInfo empty getBasename with more than one slash
Regressed in 13e4ce386b.

Closes GH-11340.
2023-05-30 17:29:18 +02:00
Máté Kocsis
85338569de Narrow bool return types to true when possible 2023-05-07 19:34:09 +02:00
nielsdos
001e278549 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11178: Segmentation fault in spl_array_it_get_current_data (PHP 8.1.18)
  Fix GH-11175 and GH-11177: Stream socket timeout undefined behaviour
  Fix GH-9068: Conditional jump or move depends on uninitialised value(s)
2023-05-03 19:49:02 +02:00
nielsdos
ab3f584a25 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11178: Segmentation fault in spl_array_it_get_current_data (PHP 8.1.18)
  Fix GH-11175 and GH-11177: Stream socket timeout undefined behaviour
  Fix GH-9068: Conditional jump or move depends on uninitialised value(s)
2023-05-03 19:46:51 +02:00
nielsdos
81e50b4ee3 Fix GH-11178: Segmentation fault in spl_array_it_get_current_data (PHP 8.1.18)
Dynamic property case in zend_get_property_info() can return NULL for
prop info. This was not handled.

Closes GH-11182.
2023-05-03 19:42:04 +02:00
Ilija Tovilo
04fd04acab
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix reference returned from CallbackFilterIterator::accept()
2023-04-20 13:43:29 +02:00
Ilija Tovilo
b2282bee32
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix reference returned from CallbackFilterIterator::accept()
2023-04-20 13:43:20 +02:00
Ilija Tovilo
5855bdcd6c
Fix reference returned from CallbackFilterIterator::accept()
Fixes oss-fuzz #58181
2023-04-20 10:18:18 +02:00
Niels Dossche
a0476fd32f
Micro-optimize double comparison (#11061)
When using ZEND_NORMALIZE_BOOL(a - b) where a and b are doubles, this
generates the following instruction sequence on x64:
subsd   xmm0, xmm1
pxor    xmm1, xmm1
comisd  xmm0, xmm1
...

whereas if we use ZEND_THREEWAY_COMPARE we get two instructions less:
ucomisd xmm0, xmm1

The only difference is that the threeway compare uses *u*comisd instead
of comisd. The difference is that it will cause a FP signal if a
signaling NAN is used, but as far as I'm aware this doesn't matter for
our use case.

Similarly, the amount of instructions on AArch64 is also quite a bit
lower for this code compared to the old code.

** Results **

Using the benchmark https://gist.github.com/nielsdos/b36517d81a1af74d96baa3576c2b70df
I used hyperfine: hyperfine --runs 25 --warmup 3 './sapi/cli/php sort_double.php'
No extensions such as opcache used during benchmarking.

BEFORE THIS PATCH
-----------------
  Time (mean ± σ):     255.5 ms ±   2.2 ms    [User: 251.0 ms, System: 2.5 ms]
  Range (min … max):   251.5 ms … 260.7 ms    25 runs

AFTER THIS PATCH
----------------
  Time (mean ± σ):     236.2 ms ±   2.8 ms    [User: 228.9 ms, System: 5.0 ms]
  Range (min … max):   231.5 ms … 242.7 ms    25 runs
2023-04-14 18:22:42 +02:00
Niels Dossche
930db2b2d3 Merge branch 'PHP-8.2'
* PHP-8.2:
  Handle indirect zvals and use up-to-date properties in SplFixedArray::__serialize
  [ci skip] NEWS
2023-03-30 22:07:48 +02:00