Commit graph

443 commits

Author SHA1 Message Date
Dmitry Stogov
1f5d9534ae Fix incorrect optimization
Fixes oss-fuzz #57482
2023-03-27 17:57:54 +03: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
Dmitry Stogov
e3aa73904a Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix updating SSA object type for *_ASSIGN_OP (#10458)
2023-02-14 11:29:47 +03: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
Dmitry Stogov
55e3f73109 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix type inference
2023-01-30 13:16:05 +03:00
Dmitry Stogov
81607a62ca Fix type inference
Fixes oss-fuzz #55358
2023-01-30 13:15:05 +03:00
Dmitry Stogov
227b3b3281 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect check condition in type inference (#10425)
2023-01-24 09:32:26 +03: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
David Carlier
385f410e4c Merge branch 'PHP-8.1' into PHP-8.2 2023-01-16 20:43:08 +00: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
Dmitry Stogov
9abc2108fa Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect optimization of ASSIGN_OP may lead to incorrect result (sub assign -> pre dec conversion for null values)
2023-01-09 13:53:19 +03: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
Dmitry Stogov
0464524292 Fix memory leak because of incorrect optimization
Fixes oss-fuzz #54488
2022-12-26 13:20:55 +03:00
Dmitry Stogov
de4b502fef Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix memory leak
2022-11-07 11:08:54 +03:00
Dmitry Stogov
f31f464cec Fix memory leak
Fixes oss-fuzz #52999
2022-11-07 11:07:58 +03:00
Dmitry Stogov
eecbb60db6 Fix memory leak
Fixes oss-fuzz #52479
2022-10-17 15:08:21 +03:00
Dmitry Stogov
94b8c2da9f Fixed type inference
Fixes oss-fuzz #51640
2022-09-26 12:19:12 +03:00
Dmitry Stogov
7496a400aa Fix SSA construction and type inference
Fixes oss-fuzz #51476
2022-09-19 15:45:34 +03:00
George Peter Banyard
6c4d24e4f0 Update cache slot size calculation in compact_literals.c 2022-09-10 13:20:59 +01:00
Dmitry Stogov
c151e9b75b Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix type inference
2022-09-05 13:01:04 +03:00
Dmitry Stogov
c852e0fff9 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference
2022-09-05 12:56:34 +03:00
Máté Kocsis
5210872747
Regenerate optimizer func info after preprocessor condition changes 2022-09-02 17:18:42 +02:00
Dmitry Stogov
218da70bcf Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix memory leak
2022-08-29 14:54:49 +03:00
Dmitry Stogov
172ac0a48d Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix memory leak
2022-08-29 14:54:40 +03:00
Dmitry Stogov
567213c32a Drop range inference for IS_NULL/IS_FALSE/IS_TRUE.
These values not always converted to IS_LONG (e.g. by -- and ++) and
this leads to incorrect range inferene and later to incorrect JIT code
generation.
2022-08-23 11:22:31 +03:00
Dmitry Stogov
e10d2c2bf9 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix type inference
2022-08-22 21:12:49 +03:00
Dmitry Stogov
95befc786a Fix type inference
Fixes oss-fuzz #50272
2022-08-22 21:11:39 +03:00
Ilija Tovilo
a6f489b452
Fix mb_strimwidth RC info
Closes GH-9254
2022-08-05 17:06:23 +02:00
sji
3b62d66098
Implement constants in traits (#8888)
RFC: https://wiki.php.net/rfc/constants_in_traits
2022-08-04 20:08:40 +01:00
Bob Weinand
dc5475c191 Save previous observer on the VM stack
This avoids a possible significant performance penalty, when some leaf function was observed, deep in the stack.
As a side effect, we are not iterating over prev_execute_data anymore and thus, non-observed fake frames, possibly on stack, cannot have any impact on the observer anymore (especially within zend_observer_fcall_end_all).

Saving the previous observer happens now directly on the VM stack. If there is any observer, function frames are allocated an extra zval (the last temporary), which will, on observed frames, contain the previous observed frame address.
2022-08-04 17:16:27 +02:00
Dmitry Stogov
21507ef28a Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix SSA reconstruction when body of "foreach" loop is removed
2022-08-01 14:01:34 +03:00
Dmitry Stogov
4b19b85eb6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix SSA reconstruction when body of "foreach" loop is removed
2022-08-01 14:01:11 +03:00
Dmitry Stogov
87cf05e8be Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix type inference
2022-07-25 15:55:15 +03:00
Dmitry Stogov
d50875c822 Fix type inference
Fixes oss-fuzz #49423 and #49474
2022-07-25 15:53:06 +03:00
Ilija Tovilo
d4a9cc8856
Fix rc info of iterator_to_array (#9080)
This function can now return a copy of the provided array, resulting in
a value of RC != 1.
2022-07-21 15:05:34 +02:00
Go Kudo
4d8dd8d258
Implement Random Extension
https://wiki.php.net/rfc/rng_extension
https://wiki.php.net/rfc/random_extension_improvement
2022-07-19 10:27:38 +01:00
Dmitry Stogov
71814e9d99 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix type inference
2022-07-18 14:20:41 +03:00
Dmitry Stogov
82d3ad64df Fix type inference
Fixes oss-fuzz #48908
2022-07-18 14:20:06 +03:00
Dmitry Stogov
26d890e6ba Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix type inference for FETCH_DI_UNSET
2022-07-18 13:15:12 +03:00
Dmitry Stogov
b734d45626 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference for FETCH_DI_UNSET
2022-07-18 13:15:03 +03:00
Ilija Tovilo
63912b5ecd
Fix RC func info of str_split (#9016)
Introduced in GH-8945

With RETURN_EMPTY_ARRAY this function can now return an interned array which
has refcount 2.
2022-07-15 11:23:55 +02:00
George Peter Banyard
f905590764
Add support for Disjoint Normal Form (DNF) types (#8725)
RFC: https://wiki.php.net/rfc/dnf_types

This allows to combine union and intersection types together in the following form (A&B)|(X&Y)|T but not of the form (X|A)&(Y|B) or (X|A)&(Y|B)|T.

* Improve union type parsing

Co-authored-by: Sara Golemon <pollita@php.net>
2022-07-08 11:30:23 +01:00
Dmitry Stogov
fa75bd0785 Fix incorrect constant propagation for VERIFY_RETURN_TYPE
This fixes oss-fuzz #48104
2022-06-20 11:30:07 +03:00
Dmitry Stogov
3d4a55fea1 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix memory leak
2022-06-20 11:00:41 +03:00
Dmitry Stogov
ee17296e7b Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix memory leak
2022-06-20 11:00:32 +03:00
Máté Kocsis
49d3dde211
Declare true return types (#8759) 2022-06-18 22:06:50 +02:00
Dmitry Stogov
20a902749a Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix type inference
2022-06-14 12:00:26 +03:00