Commit graph

18076 commits

Author SHA1 Message Date
Ilija Tovilo
8340d75d17
Endless recursion when using + on array in foreach
This reverts commit 84b4020eb4.

Fixes GH-11171
2023-05-01 09:21:04 -04:00
nielsdos
7300659391 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Set error_log to an empty value if the test relies on that feature
2023-04-24 23:23:45 +02:00
Niels Dossche
691ff9f845 Set error_log to an empty value if the test relies on that feature
Some tests fail if the error_log is overriden by the loaded ini
configuration. Explicitly set it to an empty value to prevent the
failures.
See https://github.com/php/php-src/issues/10737#issuecomment-1452899299

Closes GH-10772.
2023-04-24 23:19:15 +02:00
Ilija Tovilo
439919c91d
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect CG(memoize_mode) state after bailout in ??=
2023-04-20 19:46:05 +02:00
Ilija Tovilo
4c38a79f09
Fix incorrect CG(memoize_mode) state after bailout in ??=
Fixes GH-11108
Closes GH-11109
2023-04-20 19:45:02 +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
Ilija Tovilo
35c1bb2e47
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Support enums in array_unique
2023-04-16 15:35:55 +02:00
Ilija Tovilo
e8b8341d3d
Support enums in array_unique
Fixes GH-9775
Closes GH-11015
2023-04-16 15:34:56 +02:00
Jakub Zelenka
9a20f43b94
Merge branch 'PHP-8.1' into PHP-8.2 2023-04-15 21:29:11 +01:00
Jakub Zelenka
0ac55e9bfb
Add zend_test_crash funtion to segfault PHP process
This is useful for testing PHP-FPM handling of crashed children.

Closes GH-11082
2023-04-15 21:25:02 +01:00
Niels Dossche
1799327356 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11028: Heap Buffer Overflow in zval_undefined_cv.
2023-04-15 18:30:47 +02:00
Niels Dossche
fc32d39b7f Fix GH-11028: Heap Buffer Overflow in zval_undefined_cv.
For analysis see https://github.com/php/php-src/issues/11028#issuecomment-1508460440

Closes GH-11083.
2023-04-15 18:22:55 +02:00
Dmitry Stogov
e14ac1caee Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Allow FETCH_OBJ_W and FETCH_STATIC_PROP_W to return INDIRECT/UNDEF zval for uninitialized typed properties (#11048)
2023-04-10 23:25:08 +03:00
Dmitry Stogov
0c65b396d6
Allow FETCH_OBJ_W and FETCH_STATIC_PROP_W to return INDIRECT/UNDEF zval for uninitialized typed properties (#11048) 2023-04-10 23:19:17 +03:00
Ilija Tovilo
c4f56c5099
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix add_function_array() assertion when op2 contains op1
2023-04-03 12:49:33 +02:00
Ilija Tovilo
84b4020eb4
Fix add_function_array() assertion when op2 contains op1
Fixes GH-10085
Closes GH-10975
Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2023-04-03 12:48:46 +02:00
Niels Dossche
0d12b3db64 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10990: mail() throws TypeError after iterating over $additional_headers array by reference
  Fix GH-8841: php-cli core dump calling a badly formed function
2023-04-01 20:04:48 +02:00
Niels Dossche
cf9b030a57 Fix GH-8841: php-cli core dump calling a badly formed function
It's actually not php-cli specific, nor SAPI specific.
We should delay the registration of the function into the function table
until after the compilation was successful, otherwise the function is
mistakingly registered and a NULL dereference will happen when trying to
call it.

I based my test of Nikita's test, so credits to him for the test:
https://github.com/php/php-src/pull/8933#issuecomment-1259881008

Closes GH-10989.
2023-04-01 19:43:09 +02:00
Ilija Tovilo
ed80a7e8c9
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Unary minus const expression consistency
2023-03-31 14:28:25 +02:00
Ilija Tovilo
41bbb116dd
Unary minus const expression consistency
- of 0.0 should result in -0.0

Closes GH-10978
2023-03-31 14:27:54 +02:00
Ben Ramsey
d9df750b22
PHP-8.1 is now for PHP 8.1.19-dev 2023-03-29 19:51:20 -05:00
Pierrick Charron
f7c692a940
PHP-8.2 is now for PHP 8.2.6-dev 2023-03-28 17:27:17 -04:00
Ilija Tovilo
69c57bea3d
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Reset EG(trampoline).op_array.last_var that FFI may modify
2023-03-27 22:59:58 +02:00
Ilija Tovilo
4e0bd03681
Reset EG(trampoline).op_array.last_var that FFI may modify
Closes GH-10916
2023-03-27 22:59:00 +02:00
Dmitry Stogov
1f5d9534ae Fix incorrect optimization
Fixes oss-fuzz #57482
2023-03-27 17:57:54 +03:00
Niels Dossche
bf487bde13 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix undefined behaviour in string uppercasing and lowercasing
2023-03-25 21:22:35 +01:00
Niels Dossche
93e0f6b424 Fix undefined behaviour in string uppercasing and lowercasing
At least on 32-bit, the address computations overflow in running the
test on CI with UBSAN enabled. Fix it by reordering the arithmetic.
Since a part of the expression is already used in the code above the
computation, this should not negatively affect performance.

Closes GH-10936.
2023-03-25 21:17:15 +01:00
Ilija Tovilo
3d8107f74c
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  By-ref modification of typed and readonly props through ArrayIterator
2023-03-25 16:23:48 +01:00
Ilija Tovilo
9aaa5cd093
By-ref modification of typed and readonly props through ArrayIterator
Fixes GH-10844
Closes GH-10872
2023-03-25 16:14:19 +01:00
Ilija Tovilo
c0bb5b0b67
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix NUL byte in exception string terminating Exception::__toString()
2023-03-19 10:50:39 +01:00
Ilija Tovilo
b5726c2cb1
Fix NUL byte in exception string terminating Exception::__toString()
Fixes GH-10810
Closes GH-10873
2023-03-19 10:48:26 +01:00
Niels Dossche
d479b5a0e7 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-8789 and GH-10015: Fix ZTS zend signal crashes due to NULL globals
2023-03-18 11:45:06 +01:00
Niels Dossche
06ae75007a Fix GH-8789 and GH-10015: Fix ZTS zend signal crashes due to NULL globals
Fixes GH-8789.
Fixes GH-10015.

This is one small part of the underlying bug for GH-10737, as in my
attempts to reproduce the issue I constantly hit this crash easily.
(The fix for the other underlying issue for that bug will follow soon.)

It's possible that a signal arrives at a thread that never handled a PHP
request before. This causes the signal globals to dereference a NULL
pointer because the TSRM pointers for the thread aren't set up to point
to the thread resources yet.

PR GH-9766 previously fixed this for master by ignoring the signal if
the thread didn't handle a PHP request yet. While this fixes the crash
bug, I think the solution is suboptimal for 3 reasons:

1) The signal is ignored and a message is printed saying there is a bug.
   However, this is not a bug at all. For example in Apache, the signal
   set up happens on child process creation, and the thread resource
   creation happens lazily when the first request is handled by the
   thread. Hence, the fact that the thread resources aren't set up yet
   is not actually buggy behaviour.

2) I believe since it was believed to be buggy behaviour, that fix was
   only applied to master, so 8.1 & 8.2 keep on crashing.

3) We can do better than ignoring the signal. By just acting in the
   same way as if the signals aren't active. This means we need to
   take the same path as if the TSRM had already shut down.

Closes GH-10861.
2023-03-18 11:44:29 +01:00
Ilija Tovilo
b1a49ff053
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix RC1 assumption for typed properties with __get
2023-03-13 10:00:17 +01:00
Ilija Tovilo
3175f24d6a
Fix RC1 assumption for typed properties with __get
Unsetting typed properties resorts back to __get which may have RC1.

Closes GH-10833
2023-03-13 09:58:49 +01:00
Niels Dossche
c4508422eb Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10801: Named arguments in CTE functions cause a segfault
2023-03-10 19:27:17 +01:00
Niels Dossche
2c53d63197 Fix GH-10801: Named arguments in CTE functions cause a segfault
Fixes GH-10801

Named arguments are not supported by the constant evaluation routine, in
the sense that they are ignored. This causes two issues:
  - It causes a crash because not all oplines belonging to the call are
    removed, which results in SEND_VA{L,R} which should've been removed.
  - It causes semantic issues (demonstrated in the test case).

This case never worked anyway, leading to crashes or incorrect behaviour,
so just prevent CTE of calls with named parameters for now.
We can choose to support it later, but introducing support for this in
a stable branch seems too dangerous.

This patch does not change the removal of SEND_* opcodes in remove_call
because the crash bug can't be triggered anymore with this patch as
there are no named parameters anymore and no variadic CTE functions
exist.

Closes GH-10811.
2023-03-10 19:22:44 +01:00
Kamil Tekiela
e223bf2015
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix strlen error message param name
2023-03-10 12:48:46 +00:00
Kamil Tekiela
ad705afc2f
Merge branch 'Fix-strlen-error-message-param-name' into PHP-8.1
* Fix-strlen-error-message-param-name:
  Fix strlen error message param name
2023-03-10 12:47:40 +00:00
Derick Rethans
a45bef0ac6 Merge branch 'PHP-8.1' into PHP-8.2 2023-03-09 13:37:19 +00:00
Derick Rethans
717335ec63 Fixed macro generation for variadics, which don't have a default value 2023-03-09 11:39:22 +00:00
Niels Dossche
7682868dd1 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-8065: opcache.consistency_checks > 0 causes segfaults in PHP >= 8.1.5 in fpm context
  Fix GH-8646: Memory leak PHP FPM 8.1
2023-03-07 20:26:57 +01:00
Niels Dossche
ff62d117a3 Fix GH-8646: Memory leak PHP FPM 8.1
Fixes GH-8646
See https://github.com/php/php-src/issues/8646 for thorough discussion.

Interned strings that hold class entries can get a corresponding slot in map_ptr for the CE cache.
map_ptr works like a bump allocator: there is a counter which increases to allocate the next slot in the map.

For class name strings in non-opcache we have:
  - on startup: permanent + interned
  - on request: interned
For class name strings in opcache we have:
  - on startup: permanent + interned
  - on request: either not interned at all, which we can ignore because they won't get a CE cache entry
                or they were already permanent + interned
                or we get a new permanent + interned string in the opcache persistence code

Notice that the map_ptr layout always has the permanent strings first, and the request strings after.
In non-opcache, a request string may get a slot in map_ptr, and that interned request string
gets destroyed at the end of the request. The corresponding map_ptr slot can thereafter never be used again.
This causes map_ptr to keep reallocating to larger and larger sizes.

We solve it as follows:
We can check whether we had any interned request strings, which only happens in non-opcache.
If we have any, we reset map_ptr to the last permanent string.
We can't lose any permanent strings because of map_ptr's layout.

Closes GH-10783.
2023-03-07 20:16:17 +01:00
Ilija Tovilo
1978a7b393
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10709: UAF in recursive AST evaluation
2023-03-06 14:58:25 +01:00
Ilija Tovilo
7202fe16b7
Fix GH-10709: UAF in recursive AST evaluation
Fixes https://oss-fuzz.com/testcase-detail/6445949468934144
Closes GH-10718
2023-03-06 14:55:34 +01:00
Kamil Tekiela
1be99faeff
Fix strlen error message param name 2023-03-04 23:25:42 +00:00
Derick Rethans
bbcc1dadea Merge branch 'PHP-8.1' into PHP-8.2 2023-03-03 16:52:26 +00:00
Derick Rethans
7fcea9d260 Add missing ZEND_ARG_VARIADIC_OBJ_TYPE_MASK macro, and use consistent class_name variable name 2023-03-03 16:51:51 +00:00
Arnaud Le Blanc
37030257b8 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS
  fix: support for timeouts with ZTS on Linux (#10141)
2023-03-03 11:45:50 +01:00