Commit graph

2416 commits

Author SHA1 Message Date
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
Nikita Popov
821a5a1239 Drop fast_div_function
This is the same as div_function nowadays.
2021-06-14 11:32:28 +02:00
George Peter Banyard
b6958bb847
Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01:00
Nikita Popov
27be6670b1 Correctly parse array_slice() argument in call_user_func_array() opt
We should be treating this argument using the normal zpp rules,
rather than performing a simple integer cast.
2021-05-31 10:38:25 +02:00
Joe Watkins
b227a72285
ReflectionFunctionAbstract::getClosureUsedVariables
Make a distinction at compile time between bind types for static
  variables

  getStaticVariables remains unchanged

  Fixes #80071
2021-05-21 15:25:35 +02:00
Dmitry Stogov
5fe2062585 Correct DWARF frame description.
Now GDB correctly shows backtraces that involves JIT-ed code for
functional/tracing JIT, HYBRID/CALL VM, x86/AArch64 CPU.
(opcache.jit_debug=0x100 should be set).
2021-05-18 18:21:08 +03:00
Nikita Popov
fd1d5ec2b4 Add ZEND_CLASS_CONST_FLAGS() macro
And drop Z_ACCESS_FLAGS(). We no longer store *only* access flags
in these.
2021-04-28 14:51:54 +02:00
Matt Brown
6cd0b48cac Implement never return type
The never type can be used to indicate that a function never
returns, for example because it always unwinds.

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

Closes GH-6761.
2021-04-19 11:27:29 +02:00
Josh Soref
462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
Dmitry Stogov
9e12dbbaf2 micro-optimization 2021-04-05 16:11:24 +03:00
Dmitry Stogov
c2fc25fdf2 Avoid reading of property name in ASSIGN_OBJ if it can be accessed through run-time cache slot. 2021-04-01 17:55:49 +03:00
Dmitry Stogov
1b94b5b61c Avoid reading of property name in FETCH_OBJ_R/IS if it can be accessed through run-time cache slot. 2021-04-01 16:18:05 +03:00
Nikita Popov
4df39f4bd0 Don't imply SILENT from NO_AUTOLOAD
We have separate flags for non-autoloading class fetches and
silent class fetches. There's no reason why NO_AUTOLOAD should
be special-cased to be implicitly silent.
2021-03-18 15:15:21 +01:00
Nikita Popov
53e9c36cd9 Add sanity check for type of read_property return value
If an internal class overrides read_property and declared property
types, make sure that the returned value matches the declared
type (in debug builds).
2021-03-16 10:42:47 +01:00
Dmitry Stogov
3d11743372 Inline "array" part of FE_FETCH_R handler into HYBRID VM 2021-03-11 22:33:01 +03:00
Dmitry Stogov
278d452a6a zend_verify_recv_arg_type_helper is not "cold". 2021-03-11 15:57:02 +03:00
Dmitry Stogov
9da66e6ad0 Optimized object conversion to array without rebulding properties HashTable 2021-03-01 22:37:37 +03:00