Commit graph

1954 commits

Author SHA1 Message Date
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
Nikita Popov
e70f1b0488 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix symtable cache being used while cleaning symtable
2021-02-15 14:59:07 +01:00
Nikita Popov
882862563a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix symtable cache being used while cleaning symtable
2021-02-15 14:58:59 +01:00
Nikita Popov
7b7d99839c Fix symtable cache being used while cleaning symtable
We need to first clean the symtable and then check whether a cache
slot is available for it. Otherwise, it may happen that a destructor
runs while cleaning the table and uses up all the remaining slots
in the cache.

This is particularly insidious because once we overflow the cache,
the first pointer we modify is symtable_cache_ptr, making it hard
to understand what happened after the fact.

Fixes oss-fuzz #30815.
2021-02-15 14:58:38 +01:00
Nikita Popov
b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

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

Closes GH-6475.
2021-02-11 21:46:13 +01:00
Nikita Popov
e396506cd6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't throw additional Error in require_once if exception already thrown
2021-02-11 09:42:05 +01:00
Nikita Popov
d80d918547 Don't throw additional Error in require_once if exception already thrown
As pointed out in comments on bug #66216.
2021-02-11 09:41:19 +01:00
Dmitry Stogov
ef51648185 Use zend_type.ce_cache__ptr for caching class resulution during argument/result type checks 2021-02-10 18:00:00 +03:00
Dmitry Stogov
4b79dba932 Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-09 22:53:57 +03:00
Nikita Popov
9d54609a19 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use E_ERROR to report arginfo/zpp mismatch
  Make NumberFormatter ctor $pattern nullable
  Make IntlDateFormatter ctor $pattern nullable
2021-02-09 14:37:41 +01:00
Nikita Popov
d4aff25473 Use E_ERROR to report arginfo/zpp mismatch
When E_CORE_ERROR is used, we don't get correct file/line information.
2021-02-09 14:36:44 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
45a4d07dd0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add support for union types for internal functions
2021-01-12 10:15:13 +01:00
Nikita Popov
973138f39d Add support for union types for internal functions
This closes the last hole in the supported types for internal
function arginfo types. It's now possible to represent unions of
multiple classes. This is done by storing them as TypeA|TypeB and
PHP will then convert this into an appropriate union type list.

Closes GH-6581.
2021-01-12 10:14:41 +01:00
Nikita Popov
22793884b6 Remove some INDIRECT handling in VM 2021-01-06 12:46:31 +01:00
Nikita Popov
27e250880b Fix bug #80537
This is an unavoidable breaking change to both the type and
parameter name.

The assertion that was supposed to prevent this was overly lax
and accepted any object type for string parameters.
2020-12-21 10:21:50 +01:00
Nikita Popov
77325c4448 Fix removal of type source during unserialization
Missed a check for info in this code. Add it, and add an assertion
in type source removal to make it easier to catch this issue.

Fixes oss-fuzz #28208 and #28257.
2020-12-04 12:56:05 +01:00
Dmitry Stogov
841b00f641 Preallocate stack space for JIT in execute_ex() to eliminate JIT prologue/epilogue. 2020-11-30 17:56:08 +03:00
Nikita Popov
085e16c301 Fix signed integer overflow
Fixes oss-fuzz #26763.
2020-10-30 12:38:27 +01:00
Nikita Popov
078df4d144 Don't allow passing unknown named params to class without ctor
See also https://externals.io/message/112083.

Closes GH-6364.
2020-10-23 09:46:55 +02:00
Sammy Kaye Powers
12306728c5
Add system ID entropy API
The `zend_system_id` is a (true global) system ID that fingerprints a process state. When extensions add engine hooks during MINIT/startup, entropy is added the system ID for each hook. This allows extensions to identify that changes have been made to the engine since the last PHP process restart.

Closes GH-5871
2020-09-18 14:26:44 -07:00
Nikita Popov
34bb5ba2ea Remove support for EXT_NOP
This is an annoying edge case that regularly gets broken. As we're
not aware of significant users of this API, and there are other
ways to hook this, remove support for EXT_NOP.
2020-09-18 11:03:08 +02:00
Nikita Popov
e3d0bc0a98 Fixed bug #80109
Skip over leading EXT_NOP, if it exists.
2020-09-17 09:59:51 +02:00
Nikita Popov
7e61c2edd8 Fix uninitialized run-time cache when resolving named param defaults
Fixes oss-fuzz #25676.
2020-09-15 16:51:56 +02:00
Dmitry Stogov
8f93709d7d micro-optimization 2020-09-15 09:39:41 +03:00