Commit graph

17391 commits

Author SHA1 Message Date
Niels Dossche
b9a5bfc355
Fix GH-10570: Assertion `(key)->h != 0 && "Hash must be known"' failed.
Fixes GH-10570, see GH-10570 for analysis.

Closes GH-10572
2023-02-24 20:40:29 +01:00
nielsdos
8959ff39d8 Fix incorrect type for return value of zend_update_static_property_ex()
zend_update_static_property_ex() returns a zend_result, but the return
value is stored here in a bool. A bool is unsigned on my system, so in
case zend_update_static_property_ex() returns FAILURE (== -1) this gets
converted to 1 instead. This is not a valid zend_result value. This
means that (transitive) callers could mistakingly think the function
succeeded while it did in fact not succeed. Fix it by changing the type
to zend_result.

Closes GH-10691.
2023-02-24 17:02:32 +00:00
Max Kellermann
d51eb1d74c
Zend/zend_ini: fix zend_result return values
The value "1" was illegal.

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-21 13:40:54 +00:00
Daniel Black
e83cda0887
ext/Zend: zend_language_scanner_defs.h as make target 2023-02-17 16:37:13 +00:00
Ilija Tovilo
7b68ff46da
Revert "Fix GH-10168: heap-buffer-overflow at zval_undefined_cv"
This reverts commit 71ddede565.
2023-02-16 14:07:17 +01:00
Niels Dossche
d94ddbed2c
Fix updating SSA object type for *_ASSIGN_OP (#10458)
The code fetched the class entry into ce for objects and static
properties. However, when the actual update needs to take place (when
result_def exists), the class entry in ce was reset to NULL. So the SSA
object type update never happened. Fetch the class entry in the
result_def>=0 case instead after the reset of ce to NULL.
2023-02-14 11:29:29 +03:00
Ben Ramsey
28d68f5013
PHP-8.1 is now for PHP 8.1.17-dev 2023-02-13 13:16:07 -06:00
Bob Weinand
95016138a5 Fix GH-10496: Fibers must not be garbage collected while implicitly suspended by resumption of another fiber 2023-02-13 16:30:21 +00:00
Arnaud Le Blanc
d721dcc2ef Fix colletion of unfinished function call in fibers
Fixes GH-10496.

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
2023-02-13 13:09:04 +01:00
Ilija Tovilo
13c34aac05
Mark test as XFAIL
See https://github.com/php/php-src/pull/10546
2023-02-11 00:21:01 +01:00
Niels Dossche
71ddede565
Fix GH-10168: heap-buffer-overflow at zval_undefined_cv
The problem is that we're using the variable_ptr in the opcode handler
*after* it has already been destroyed. The solution is to create a
specialised version of zend_assign_to_variable which takes in two
destination zval pointers.

Closes GH-10524
2023-02-08 01:06:50 +01:00
Max Kellermann
0752baa583 Zend/zend_cpuinfo, ext/standard/crc32_x86: fix -Wstrict-prototypes
In plain C, a function without arguments must be explicitly declared
(void).

Close GH-10528
2023-02-07 22:47:43 +00:00
Niels Dossche
49551d7c29 Sync boost/context assembly files for fibers
Fixes GH-10398

The stack was misaligned upon entering the trampoline function [1], this
causes a CPU trap when the SSE instruction is executed to copy data from
the stack. This was fixed upstream [2]. This commit syncs all upstream
changes from the boost/context assembly files to our copy.

[1] https://github.com/php/php-src/pull/10407#issuecomment-1404180877
[2] https://github.com/boostorg/context/pull/219

Closes GH-10407.
2023-02-05 16:40:54 +00:00
Bob Weinand
00be6e1aed Look at executing generator for fiber destructor behaviour 2023-01-30 12:32:53 +01:00
Bob Weinand
b9bca2dadb Fix resetting ZEND_GENERATOR_IN_FIBER flag
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2023-01-30 12:13:07 +01:00
Dmitry Stogov
81607a62ca Fix type inference
Fixes oss-fuzz #55358
2023-01-30 13:15:05 +03:00
Aaron Piotrowski
284c29328e
Fix GH-10437: Set active fiber to null on bailout (#10443) 2023-01-28 10:13:58 -06:00
Arnaud Le Blanc
1173c2e64a
Prevent dtor of generator in suspended fiber (#10462)
Generators that suspended a fiber should not be dtor because they will be
executed during the fiber dtor.

Fiber dtor throws an exception in the fiber's context in order to unwind and
execute finally blocks, which will also properly dtor the generator.

Fixes GH-9916
2023-01-27 19:32:25 +01:00
Arnaud Le Blanc
9830204213
Handle non-INDIRECT symbol table entries in zend_fiber_object_gc() (#10386)
Fixes GH-10340
2023-01-27 10:52:42 +01:00
Niels Dossche
2787e3cd65
Fix incorrect check condition in type inference (#10425)
The "nothing to do" case would never be hit because the switch block
would execute if the opcode is ZEND_ASSIGN_STATIC_PROP_OP,
not ZEND_ASSIGN_STATIC_PROP. This meant that we were falling through to
the else block. Fix this by correcting the check condition.
2023-01-24 09:32:07 +03:00
Niels Dossche
0801c567dc Fix GH-10248: Assertion `!(zval_get_type(&(*(property))) == 10)' failed.
The assertion failure was triggered in a debug code-path that validates
property types for internal classes.
zend_verify_internal_read_property_type was called with retval being a
reference, which is not allowed because that function eventually calls to
i_zend_check_property_type, which does not expect a reference.
The non-debug code-path already takes into account that retval can be a
reference, as it optionally dereferences retval.

Add a dereference in zend_verify_internal_read_property_type just before
the call to zend_verify_property_type, which is how other callers often
behave as well.
2023-01-20 16:40:15 +01:00
Niels Dossche
b5e9bf7775
Fix incorrect check condition in ZEND_YIELD
The condition `UNEXPECTED(Z_TYPE_P(key)) == IS_REFERENCE` always
returned false, because `UNEXPECTED(expression)` always returns 0 or 1.
Move the parens so the comparison is executed properly.

Closes GH-10332.
2023-01-18 16:23:38 +01:00
Patrick Allaert
c47a1a260d
PHP-8.1 is now for PHP 8.1.16-dev 2023-01-17 17:24:25 +01:00
Niels Dossche
dfe9c2af19 Fix incorrect comparison in block optimization pass
We're in the case of ZEND_JMPZ_EX or ZEND_JMPNZ_EX. The opcode gets
overwritten and only after the overwriting gets checked if we're in a
JMPZ or JMPNZ case. This results in a wrong optimization.

Close GH-10329
2023-01-16 20:41:33 +00:00
Arnaud Le Blanc
0f7625c47c
Reduce HT_MAX_SIZE to account for the max load factor of 0.5 (#10242)
zend_hash allocates a hash table twice as big as nTableSize
(HT_HASH_SIZE(HT_SIZE_TO_MASK(nTableSize)) == nTableSize*2), so HT_MAX_SIZE
must be half the max table size or less.

Fixes GH-10240
2023-01-13 12:05:51 +01:00
Arnaud Le Blanc
4fb149390a
GC fiber unfinished executions (#9810) 2023-01-13 12:04:28 +01:00
Niels Dossche
833b45ac44 Fix GH-10249: Assertion `size >= page_size + 1 * page_size' failed.
Co-authored-by: Changochen <changochen1@gmail.com>

Closes GH-10284
2023-01-12 22:00:00 +00:00
Kévin Dunglas
55514a1119
fix: indirect_return compilation warning
Closes GH-10274

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-10 15:23:15 +00:00
Dmitry Stogov
4d4a53beee Fix incorrect optimization of ASSIGN_OP may lead to incorrect result (sub assign -> pre dec conversion for null values) 2023-01-09 13:51:57 +03:00
Niels Dossche
d03025bf59 Fix GH-10251: Assertion `(flag & (1<<3)) == 0' failed.
zend_get_property_guard previously assumed that at least "str" has a
pre-computed hash. This is not always the case, for example when a
string is created by bitwise operations, its hash is not set. Instead of
forcing a computation of the hashes, drop the hash comparison.

Closes GH-10254

Co-authored-by: Changochen <changochen1@gmail.com>

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-08 16:09:59 +00:00
George Peter Banyard
44add3c791 Add secondary test that registers a trampoline as a shutdown function 2022-12-23 16:34:57 +00:00
Derick Rethans
b489e0f2b8 Make sure to disable JIT when overriding execute_ex 2022-12-23 16:34:57 +00:00
Derick Rethans
233ffccc35 Fix GH-10072: PHP crashes when execute_ex is overridden and a __call trampoline is used from internal code 2022-12-23 16:34:57 +00:00
Dmitry Stogov
683285165e Fix memory leak
Fixes oss-fuzz #54320
2022-12-19 12:11:16 +03:00
Ben Ramsey
696bb385df
PHP-8.1 is now for PHP 8.1.15-dev 2022-12-07 11:29:37 -06:00
Arnaud Le Blanc
adc23828b4
Fallback to first line of function when ex->opline is NULL (#10003)
ex->opline can be null due to missing SAVE_OPLINE() in the VM

Fixes GH-9933
2022-12-02 17:21:30 +01:00
蝦米
93592ea743
Fix GH-9769: Misleading error message for unpacking of objects
Only arrays can be unpacked in constant expressions.

Closes GH-9776.
2022-12-02 13:10:59 +01:00
Michael Voříšek
8d65c2fee5
Fix GH-9650: Can't initialize heap: [0x000001e7]
Closes GH-9721.
2022-11-17 14:16:10 +01:00
Patrick Allaert
540488c74e
PHP-8.1 is now for PHP 8.1.14-dev 2022-11-08 17:57:34 +01:00
Dmitry Stogov
f31f464cec Fix memory leak
Fixes oss-fuzz #52999
2022-11-07 11:07:58 +03:00
Arnaud Le Blanc
4011657719 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] NEWS
  Fix generator memory leaks when interrupted during argument evaluation (#9756)
2022-11-04 15:59:14 +01:00
Arnaud Le Blanc
5d1f3e047c
Fix generator memory leaks when interrupted during argument evaluation (#9756) 2022-11-04 15:55:55 +01:00
David Carlier
fe06c5ef60 Merge branch 'PHP-8.0' into PHP-8.1 2022-10-23 00:46:25 +01:00
Adam Saponara
45e224cf51 Fix GH-9709: Guard against current_execute_data==NULL in is_handle_exception_set 2022-10-23 00:46:05 +01:00
Arnaud Le Blanc
ebe58459aa Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] NEWS
  Fix compilation warning
  Fix crash when memory limit is exceeded during generator initialization
2022-10-22 10:44:06 +02:00
Arnaud Le Blanc
26c7c82d32 Fix crash when memory limit is exceeded during generator initialization 2022-10-22 10:40:28 +02:00
Arnaud Le Blanc
2831e0c624 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] NEWS
  Restore extra_named_params when restoring frozen call stack
2022-10-16 12:43:34 +02:00
Arnaud Le Blanc
86e1fea39a Restore extra_named_params when restoring frozen call stack 2022-10-16 12:40:09 +02:00
Ben Ramsey
865161af33
PHP-8.1 is now for PHP 8.1.13-dev 2022-10-11 19:47:00 -04:00
Dmitry Stogov
c083efb779 Fix memory leak
Fixes oss-fuzz #51622
2022-09-26 12:02:03 +03:00