Commit Graph

2232 Commits

Author SHA1 Message Date
Nikita Popov
da0d246e19 Drop FREE_OP_VAR_PTR() distinction
FREE_OP_VAR_PTR() is like FREE_OP(), but only frees VAR, rather
than VARs and TMPs. I don't think this distinction makes sense
anymore, as opcodes using FREE_OP_VAR_PTR() generally only accept
VAR or CV. For the cases where other op types are accepted and
only freeing VAR is desired we already have FREE_OP_IF_VAR().

This drops FREE_OP_VAR_PTR(), leaving only FREE_OP() and
FREE_OP_IF_VAR().
2021-10-20 12:02:09 +02:00
Nikita Popov
08cbb99451 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix inc/dec of undef var with error handler
2021-10-19 14:19:41 +02:00
Nikita Popov
22b6aac66f Fix inc/dec of undef var with error handler
Set the variable to null after emitting the undef var notice
rather than before. This avoids an assertion failure if the var
is unset by the error handler.

The flip side is that this may cause a leak instead, but that's
the more harmless outcome.

Fixes oss-fuzz #36604.
2021-10-19 14:19:22 +02:00
Nikita Popov
ebaed43473 Merge branch 'PHP-8.1'
* PHP-8.1:
  Don't free FETCH_W operand if GLOBAL_LOCK
2021-10-12 12:46:03 +02:00
Nikita Popov
7b0710695b Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't free FETCH_W operand if GLOBAL_LOCK
2021-10-12 12:45:49 +02:00
Nikita Popov
a2e3ca1f5b Don't free FETCH_W operand if GLOBAL_LOCK
The error path performed the free unconditionally, while we should
not do it for GLOBAL_LOCK.

Fixes oss-fuzz #39868.
2021-10-12 12:44:35 +02:00
Nikita Popov
be323b89cd Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix duplicate undef warning in assign_dim_op
2021-10-05 15:51:35 +02:00
Nikita Popov
02c5f7f927 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix duplicate undef warning in assign_dim_op
2021-10-05 15:51:30 +02:00
Nikita Popov
11a9b036a8 Fix duplicate undef warning in assign_dim_op
In case of auto-vivification we were fetching dim twice and as
such also emitting the undef var warning twice.
2021-10-05 15:51:11 +02:00
Nikita Popov
f4e06ea562 Merge branch 'PHP-8.1'
* PHP-8.1:
  Create reference wrappers in SEND_UNPACK if necessary
2021-09-30 14:56:53 +02:00
Nikita Popov
02244d5ee6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Create reference wrappers in SEND_UNPACK if necessary
2021-09-30 14:56:44 +02:00
Nikita Popov
e11faad233 Create reference wrappers in SEND_UNPACK if necessary
Even if we can't actually pass by reference, we still need to
create the REFERENCE wrapper to satisfy the calling convention.
The particular test case would crash with JIT, because the existence
of the reference was assumed.

Fixes oss-fuzz #39440.
2021-09-30 14:55:48 +02:00
Nikita Popov
e1f98447d9 Merge branch 'PHP-8.1'
* PHP-8.1:
  Handle throwing destructor in BIND_STATIC
2021-09-29 10:17:27 +02:00
Nikita Popov
9346da8964 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle throwing destructor in BIND_STATIC
2021-09-29 10:17:22 +02:00
Nikita Popov
ec54ffad1e Handle throwing destructor in BIND_STATIC
Fixes oss-fuzz #39406.
2021-09-29 10:17:05 +02:00
Nikita Popov
5ce32368f2 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix SEND_USER with ref arg
2021-09-17 12:18:27 +02:00
Nikita Popov
92f808b8bc Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix SEND_USER with ref arg
2021-09-17 12:18:16 +02:00
Nikita Popov
01453a0af7 Fix SEND_USER with ref arg
Even though the input is not a reference (or not treated as such),
we still need to create a reference to satisfy the function
signature. Various code relies on reference arguments actually
being references. In this particular case, it would result in
a JIT crash.

The zend_call_function() implementation already handled this
correctly.
2021-09-17 12:17:33 +02:00
Nikita Popov
6446eafb74 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix memory leak in array unpack with refcounted numeric string key
2021-09-14 12:14:51 +02:00
Nikita Popov
260d2acdb4 Fix memory leak in array unpack with refcounted numeric string key 2021-09-14 12:14:12 +02:00
Nikita Popov
6381a16f3f Avoid use after free in internal prop type verification
This issue only applies to debug builds: read_property can free
the object, but we'd try to check the object handlers afterwards.
Rewrite the check in a way that only accessed the object before
the read_property call.

Fixes oss-fuzz #38297.
2021-09-09 15:30:32 +02:00
Nikita Popov
a40ccd758c Fixed bug #81377
BP_VAR_UNSET should not result in undefined warnings.
2021-08-24 15:05:53 +02:00
Christoph M. Becker
7c53e7def8
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #73122: Integer Overflow when concatenating strings
2021-08-18 14:54:29 +02:00
Christoph M. Becker
d71a0dcc76
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73122: Integer Overflow when concatenating strings
2021-08-18 14:52:59 +02:00
Christoph M. Becker
0b7dffb41f
Fix #73122: Integer Overflow when concatenating strings
We must avoid integer overflows in memory allocations, so we introduce
an additional check in the VM, and bail out in the rare case of an
overflow.

Closes GH-7381.
2021-08-18 14:49:09 +02:00
Nikita Popov
6d5ae6496c Fix ASSIGN_DIM to NEXT with rc=1 reference value
The reference wrapper was destroyed while value still pointed into
it and was later used to assign the ASSIGN_DIM return value. This
could be fixed either by moving the return value assignment earlier,
or by working with the value that has been stored in the array.
I'm going with the latter here, because that matches what the
non-NEXT codepath does via assign_to_variable more closely.

Fixes oss-fuzz #36807.
2021-08-03 10:25:24 +02:00
Joe Watkins
05ef6334cd
Fix bug #81303 improve match errors 2021-08-02 17:31:26 +02:00
Nikita Popov
9e66455fbc Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix parameter name in count() error message
2021-07-29 14:25:22 +02:00
Nikita Popov
6c7b322de2 Fix parameter name in count() error message
This parameter has been renamed to $value.
2021-07-29 14:25:13 +02:00
Hao Sun
60ea2cbf74
Fix a typo in function execute_ex (#7315) 2021-07-29 13:49:31 +02:00
Nikita Popov
fc45223f85 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix parameter name in call_user_func() error message
2021-07-29 12:49:17 +02:00
Nikita Popov
840e441d2d Fix parameter name in call_user_func() error message
This parameter name has been changed to $callback.
2021-07-29 12:48:25 +02:00
Nikita Popov
e011952576
Preload unlinked classes, remove preload autoload (#7311)
Currently, classes that can't be linked get moved back into the original script
and are not preloaded. As such classes may be referenced from functions that
did get preloaded, there is a preload autoload mechanism to load them at
runtime.

Since PHP 8.1, we can safely preload unlinked classes, which will then go
through usual lazy loading. This means that we no longer need the preload
autoload mechanism. However, we need to be careful not to modify any hash
table buckets in-place, and should create new buckets for lazy loaded classes.
2021-07-28 14:27:58 +02:00
Nikita Popov
dcf5e5bbf0 Reuse part of the class binding logic
This part of DECLARE_CLASS and DECLARE_CLASS_DELAYED is the
same.
2021-07-27 16:54:45 +02:00
Nikita Popov
7b85d3bbdd Add support for verifying optimizer func info
This is guarded by -DZEND_VERIFY_FUNC_INFO=1. Enable this on the
variation job.

Closes GH-6924.
2021-07-21 12:24:30 +02:00
Levi Morrison
ae8647d9d3
Remove leading underscore for _zend_hash_find_known_hash (#7260)
Convert zend_hash_find_ex(..., 1) to zend_hash_find_known_hash(...)
Convert zend_hash_find_ex(..., 0) to zend_hash_find(...)

Also add serializable changes to UPGRADING.INTERNALS summary
2021-07-20 17:07:17 -06:00
Nikita Popov
6780aaa532 Implement readonly properties
Add support for readonly properties, for which only a single
initializing assignment from the declaring scope is allowed.

RFC: https://wiki.php.net/rfc/readonly_properties_v2

Closes GH-7089.
2021-07-20 12:05:46 +02:00
Kamil Tekiela
052af90b86 Deprecate autovivification on false
Deprecate automatically converting "false" into an empty array
on write operands. Autovivification continues to be supported
for "null" values, as well as undefined/uninitialized values.

RFC: https://wiki.php.net/rfc/autovivification_false

Closes GH-7131.

Co-authored-by: Tyson Andre <tysonandre775@hotmail.com>
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 14:49:37 +02:00
Nikita Popov
90e6a74016 Merge branch 'PHP-8.0'
* PHP-8.0:
  Drop incorrect cache_slot optimization for typed properties
2021-07-14 15:10:58 +02:00
Nikita Popov
982c833acd Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Drop incorrect cache_slot optimization for typed properties
2021-07-14 15:10:11 +02:00
Nikita Popov
ba8bcf3992 Drop incorrect cache_slot optimization for typed properties
For a particular assignment, a non-coerced constant assignment
value will remain valid. However, opcache merges cache slots for
all identical property references, which means that this
optimization also disables property type checks for all other
operands on the property that occur in the same functions.

This could be addressed by blocking cache slot merging in opcache,
but I prefer dropping it entirely instead. It does not seem
important enough to warrant doing that.
2021-07-14 15:08:33 +02:00
Joe Watkins
d0b09a7be4 Add first-class callables
Support acquiring a Closure to a callable using the syntax
func(...), $obj->method(...), etc. This is essentially a
shortcut for Closure::fromCallable().

RFC: https://wiki.php.net/rfc/first_class_callable_syntax

Closes GH-7019.

Co-Authored-By: Nikita Popov <nikita.ppv@gmail.com>
2021-07-14 14:37:25 +02:00
Nikita Popov
a80360dbed Deprecate direct access to static trait members
Static trait members may only be accessed through a class in which
the trait is used, not directly on the trait.

A complication here is that we should not store static
methods/properties for which a deprecation is triggered in a
cache slot. As the check for this is simple and cheap, I'm handling
this in the cache slot population code in the VM. The alternative
would be to pass the cache slot down into the fetching code.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-09 14:12:28 +02:00
George Peter Banyard
069a9fa5e4
Pure Intersection types (#6799)
Implement pure intersection types RFC

RFC: https://wiki.php.net/rfc/pure-intersection-types

Co-authored-by: Nikita Popov <nikic@php.net>
Co-authored-by: Ilija Tovilo <ilutov@php.net>
2021-07-05 14:11:03 +02:00
Nikita Popov
3321440166 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix return value of wrong fucntion by-ref assign
2021-07-02 11:18:46 +02:00
Nikita Popov
6617829f1b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix return value of wrong fucntion by-ref assign
2021-07-02 11:18:09 +02:00
Nikita Popov
96bf925cde Fix return value of wrong fucntion by-ref assign
We should be using the result of zend_assign_to_variable() here,
which will deref prior to potential freeing.

Fixes oss-fuzz #29899.
2021-07-02 11:15:31 +02:00
Nikita Popov
353f963bba Init STRLEN result when deprecation promoted to exception
Move the result initialization before HANDLE_EXCEPTION(), the
actual value doesn't matter.

This fixes one of the issues report in bug #81190.
2021-07-01 16:22:27 +02:00
Nikita Popov
b64213872a Fix missing error for single index unset on wrong type
The error was correctly thrown for a nested index, but not for a
single index. Make sure both have the same behavior.
2021-06-15 14:41:11 +02:00
Nikita Popov
34257e1cfc Remove unnecessary IS_UNUSED check
This operand cannot be UNUSED.
2021-06-15 14:27:41 +02:00