Commit graph

233 commits

Author SHA1 Message Date
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
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
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
81607a62ca Fix type inference
Fixes oss-fuzz #55358
2023-01-30 13:15:05 +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
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
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
f31f464cec Fix memory leak
Fixes oss-fuzz #52999
2022-11-07 11:07:58 +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
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
95befc786a Fix type inference
Fixes oss-fuzz #50272
2022-08-22 21:11:39 +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
d50875c822 Fix type inference
Fixes oss-fuzz #49423 and #49474
2022-07-25 15:53:06 +03:00
Dmitry Stogov
82d3ad64df Fix type inference
Fixes oss-fuzz #48908
2022-07-18 14:20:06 +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
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
Dmitry Stogov
729be469ae Fix type inference
This dixes oss-fuzz #47921
2022-06-14 11:59:35 +03:00
Dmitry Stogov
1b45efb6fb Fix type inference
This fixes oss-fuzz #47920
2022-06-14 10:20:45 +03:00
Dmitry Stogov
b86c6245cc Fix type inference
This fixes oss-fuzz #47777
2022-06-06 11:13:53 +03:00
Dmitry Stogov
c430116a11 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix memory leak
2022-05-16 13:48:40 +03:00
Dmitry Stogov
aad5fbac85 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference
2022-05-16 12:42:04 +03:00
Arnaud Le Blanc
332bd03782
Do not optimize out ini_get() when the entry does not exist during compilation (#8507)
The entry may exist later if dl is enabled

Fixes GH-8466
2022-05-13 12:35:00 +02:00
Dmitry Stogov
84c1e99ecf Fix type inference
This fizes oss-fuzz #47044
2022-05-11 12:39:26 +03:00
Dmitry Stogov
f1fc58ed8d Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference
2022-05-11 12:09:53 +03:00
Dmitry Stogov
948ef10dd0 Fix ISSET_ISEMPTY_VAR missoptimization
This fixes oss-fuzz #46909
2022-04-25 13:31:01 +03:00
Dmitry Stogov
1aa5e9392d Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Reorder optimization passes to avoid miss-optimization
2022-04-25 13:09:31 +03:00
Dmitry Stogov
e14dc15e13 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference
2022-04-25 12:17:07 +03:00
Dmitry Stogov
2cff0e674d Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type narrowing warning during type inference of ZEND_FETCH_DIM_W
2022-04-25 11:17:04 +03:00
Nikita Popov
18b4e36df1 Move check for named params in fcall optimization earlier
I don't think this is strictly necessary, but I think it makes
sense to check this before interpreting opline->op2.num as an
argument number.

This also adds one more has_known_send_mode() check that I had
missed before.
2022-04-18 18:21:24 +02:00
Nikita Popov
11f950e77e Don't optimize trailing args for prototype fbc 2022-04-18 17:57:16 +02:00
Nikita Popov
b0ab5d0fb0 Don't set ce for by-ref return type
For the case where we upgrade a prototype to a possible by-ref
return from an inheriting method.
2022-04-15 23:55:48 +02:00
Nikita Popov
4026daee2b Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Move MAY_BE_REF check into COPY_SSA_OBJ_TYPE
2022-04-15 23:14:59 +02:00
Nikita Popov
38547b996a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't use CE for by-ref arguments
2022-04-15 23:00:59 +02:00
Nikita Popov
f1814e6a1f Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't use CE info from pi node for MAY_BE_REF var
2022-04-15 22:37:29 +02:00
Nikita Popov
3fdb1aa14e Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix inference for assignment of known object to reference
2022-04-15 22:15:32 +02:00
Nikita Popov
c72e9621ce Improve type narrowing fix
We need to explicitly model the null return type for property
accesses on non-objects.
2022-04-10 11:22:36 +02:00
Nikita Popov
323f3c6914 Improve file/line information for narrowing warning
Report the file/line of the opline rather than the include location.

This should make issues like #8251 easier to debug.
2022-04-10 10:41:20 +02:00
Dmitry Stogov
e721a42211 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed reference counting inference
2022-04-04 15:34:46 +03:00
Dmitry Stogov
156d3aedc1 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix memory leak
2022-03-14 12:58:11 +03:00
Dmitry Stogov
770a544af4 Optimizer: Fix inorrect constant substitution in FETCH_LIST_R
Fixes oss-fuzz #45429
2022-03-11 14:30:27 +03:00
Dmitry Stogov
1f5562aa09 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed memory leak
2022-03-11 11:33:01 +03:00
Dmitry Stogov
aced867a95 Fix typr inference
Fixes oss-fuzz #45020
2022-02-28 18:25:49 +03:00
Dmitry Stogov
56d7672d56 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed incorrect DCE for FREE
2022-02-28 11:54:25 +03:00
Christoph M. Becker
33cd61c904
Fix GH-8140: Wrong first class callable by name optimization
When optimizing by name function calls, we must not replace
`CALLABLE_CONVERT` opcodes, but have to keep them.

Closes GH-8144.
2022-02-24 10:35:53 +01:00
Christoph M. Becker
7ea3b19331
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8074: Wrong type inference of range() result
2022-02-22 10:20:13 +01:00
Dmitry Stogov
7e8257fbd2 Disable ASSIGN optimization for values inferred for fatal errors. 2022-02-18 11:35:43 +03:00
Dmitry Stogov
0eb96b6e13 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference
2022-02-11 13:04:12 +03:00
Dmitry Stogov
34c2324fbf Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix too aggressive DCE that leads to memory leak
2022-01-28 12:18:47 +03:00
Dmitry Stogov
9824735aa4 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference
2022-01-10 21:54:14 +03:00
Dmitry Stogov
906cb52c63 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed NAN handling in SCCP
2022-01-10 19:40:22 +03:00