Commit Graph

1828 Commits

Author SHA1 Message Date
Nikita Popov
14f599ea7d Use zend_long for resource ID
Currently, resource IDs are limited to 32-bits. As resource IDs
are not reused, this means that resource ID overflow for
long-running processes is very possible.

This patch switches resource IDs to use zend_long instead, which
means that on 64-bit systems, 64-bit resource IDs will be used.
This makes resource ID overflow practically impossible.

The tradeoff is an 8 byte increase in zend_resource size.

Closes GH-7436.
2021-08-31 14:58:59 +02:00
Nikita Popov
5b2ddf5a17 Export zend_use_resource_as_offset()
Use a common implementation to generate this error message, as
we do so in quite a few places dealing with array keys.
2021-08-31 10:58:01 +02:00
Nikita Popov
315f40942b
Always use CE_CACHE, remove TYPE_HAS_CE (#7336)
Currently, CE_CACHE on strings is only used with opcache interned strings. This
patch extends usage to non-opcache interned strings as well. This means that
most type strings can now make use of CE_CACHE even if opcache is not loaded,
which allows us to remove TYPE_HAS_CE kind, and fix some discrepancies
depending on whether a type stores a resolved or non-resolved name.

There are two cases where CE_CACHE will not be used:

 * When opcache is not used and a permanent interned string (that is not an
   internal class name) is used as a type name during the request. In this case
   we can't allocate a map_ptr index for the permanent string, as it would be
   not be in the permanent map_ptr index space.
 * When opcache is used but the script is not cached (e.g. eval'd code or
   opcache full). If opcache is used, we can't allocate additional map_ptr
   indexes at runtime, because they may conflict with indexes allocated by
   opcache.

In these two cases we would end up not using CE caching for property types
(argument/return types still have the separate cache slot).
2021-08-11 10:28:52 +02:00
Joe Watkins
05ef6334cd
Fix bug #81303 improve match errors 2021-08-02 17:31:26 +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
c50f4dece0 Fix typo in comment
[ci skip]
2021-07-20 12:44:05 +02: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
ee65e92070 Check internal function type consistency in zend_call_function
We do this for calls in the engine, but not those going through
zend_call_function().
2021-07-13 11:50:07 +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
629965c80f Handle promoted exception in int|string type
Fixes oss-fuzz #35790.
2021-07-05 10:48:20 +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
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Dmitry Stogov
973ae8d3e2 Move the whole "cold" path into the "cold" function. 2021-06-23 14:55:58 +03:00
George Peter Banyard
4939d2cec1
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test
  Fix bug #81159: Object to int warning when using an object as a string offset
  Fix bug #81163 indirect vars in __sleep
2021-06-18 18:11:46 +01:00
George Peter Banyard
f0fd5922ee
Fix bug #81159: Object to int warning when using an object as a string offset
Closes GH-7167
2021-06-18 18:07:22 +01:00
Dmitry Stogov
3a78259525 JIT: Avoid too aggressive loop unrolling
This fixes tests/func/010.phpt failure with tracing JIT on ARM64.
2021-06-16 16:44:27 +03:00
Joe Watkins
cb3964aae4
move zend_vm_stack_new_page into header for sharing with fibers 2021-06-10 15:20:29 +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
c27dedb0c7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81090
2021-05-31 12:34:21 +02:00
Nikita Popov
ee74f2e57f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81090
2021-05-31 12:33:59 +02:00
Nikita Popov
82f6f6da67 Fixed bug #81090
For concatenation, the in-place variant can be much more efficient,
because it will reallocate the string in-place. Special-case the
typed property compound assignment code for the case where we
concatenate to a string, in which case we know that the result
will also be a string, and we don't need the type check anyway.
2021-05-31 12:31:56 +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
Máté Kocsis
532c60cb92
Add support for tentative return types of internal methods
RFC: https://wiki.php.net/rfc/internal_method_return_types

Closses GH-6971
2021-05-14 15:55:25 +02:00
George Peter Banyard
7372a3e117
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Bug #80972: Memory exhaustion on invalid string offset
2021-04-26 13:22:37 +01:00
George Peter Banyard
97f8ca52fa
Fix Bug #80972: Memory exhaustion on invalid string offset
Closes GH-6909
2021-04-26 13:22:12 +01:00
George Peter Banyard
418fcd22e8
Fix Bug #80972: Memory exhaustion on invalid string offset
Closes GH-6890
2021-04-26 13:21:40 +01: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
Nikita Popov
b196d4ae3e Accept zend_string instead of zval in compile_filename 2021-04-09 14:33:34 +02:00
Dmitry Stogov
d8e4fbae62 Fast Class Cache
This is generalization of idea, that was previously usesd for caching
resolution of class_entries in zend_type. Now very similar mechanizm is
used for general zend_string into zend_class_entry resolution.

Interned zend_string with IS_STR_CLASS_NAME_MAP_PTR GC_FLAG uses its
refcount to adress corresponding zend_class_entry cache slot.
The refcount keeps an offset to this slot from CG(map_ptr_base).
Flag may be checked by ZSTR_HAS_CE_CACHE(str), cache slot may be read by
ZSTR_GET_CE_CACHE(str) and set by ZSTR_SET_CE_CACHE(str, ce).
2021-04-08 23:37:40 +03:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Dmitry Stogov
368766ec28 Set expectations 2021-04-05 15:21:13 +03:00
Dmitry Stogov
24388fd573 Merge branch 'PHP-8.0'
* PHP-8.0:
  Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
2021-03-31 13:12:00 +03:00
Dmitry Stogov
e0996decc3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
2021-03-31 13:11:11 +03:00
Dmitry Stogov
39d8fc1edc Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
Old registers (r28/r29) might be clobbered by _restgpr routine used for return from C function compiled with -Os.
2021-03-31 13:10:21 +03:00
George Peter Banyard
56c18c4038 Drop unneessary if branch and adjust arg_num type
This if branch seems to be a remain of when certain type errors where E_WARNINGs, something which isn't the case since PHP 8.0.
2021-03-25 02:12:06 +00:00
Dmitry Stogov
340013ad01 Add zend_hash_lookup() and zend_hash_index_lookup() functions.
Thet search for an element with given key/index and add an empty one (NULL), if no found.
2021-03-19 22:36:24 +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
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Nikita Popov
59e610092a Check for WRONG_PROPERTY_INFO 2021-03-16 14:24:48 +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
Nikita Popov
056eac6b03 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80811
2021-03-01 16:30:19 +01:00
Nikita Popov
75a4f484f0 Fixed bug #80811
When filling in defaults for skipped params, make sure that
reference parameters get the expected reference wrapper.
2021-03-01 16:30:01 +01:00
Nikita Popov
8e8e0017b9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix trampoline leak on dynamic static call of non-static method
2021-02-22 10:33:16 +01:00
Nikita Popov
ab98944195 Fix trampoline leak on dynamic static call of non-static method
Fixes oss-fuzz #30317.
2021-02-22 10:32:59 +01:00
Nikita Popov
6dd85f83f7 Fixed bug #80781
zend_find_array_dim_slow() may throw, make sure to handle this.
This backports the code we already use for this on PHP-8.0,
and also backports an exception check that makes this easier to
catch.
2021-02-22 09:36:43 +01:00