summaryrefslogtreecommitdiff
path: root/Zend/zend_execute.c
Commit message (Collapse)AuthorAgeFilesLines
* Drop unneessary if branch and adjust arg_num typeGeorge Peter Banyard2021-03-251-7/+1
| | | | 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.
* Add zend_hash_lookup() and zend_hash_index_lookup() functions.Dmitry Stogov2021-03-191-39/+42
| | | | Thet search for an element with given key/index and add an empty one (NULL), if no found.
* Don't imply SILENT from NO_AUTOLOADNikita Popov2021-03-181-2/+3
| | | | | | 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.
* Change Zend Stream API to use zend_string* instead of char*.Dmitry Stogov2021-03-161-5/+7
| | | | | This allows to eliminate re-calculation of string lenght and hash value. See the detailed list of changes in UPGRADING.INTERNALS.
* Check for WRONG_PROPERTY_INFONikita Popov2021-03-161-1/+1
|
* Add sanity check for type of read_property return valueNikita Popov2021-03-161-0/+9
| | | | | | If an internal class overrides read_property and declared property types, make sure that the returned value matches the declared type (in debug builds).
* Merge branch 'PHP-8.0'Nikita Popov2021-03-011-0/+3
|\ | | | | | | | | * PHP-8.0: Fixed bug #80811
| * Fixed bug #80811Nikita Popov2021-03-011-0/+3
| | | | | | | | | | When filling in defaults for skipped params, make sure that reference parameters get the expected reference wrapper.
* | Merge branch 'PHP-8.0'Nikita Popov2021-02-221-0/+8
|\ \ | |/ | | | | | | * PHP-8.0: Fix trampoline leak on dynamic static call of non-static method
| * Fix trampoline leak on dynamic static call of non-static methodNikita Popov2021-02-221-0/+8
| | | | | | | | Fixes oss-fuzz #30317.
* | Merge branch 'PHP-8.0'Nikita Popov2021-02-151-3/+4
|\ \ | |/ | | | | | | * PHP-8.0: Fix symtable cache being used while cleaning symtable
| * Merge branch 'PHP-7.4' into PHP-8.0Nikita Popov2021-02-151-3/+4
| |\ | | | | | | | | | | | | * PHP-7.4: Fix symtable cache being used while cleaning symtable
| | * Fix symtable cache being used while cleaning symtableNikita Popov2021-02-151-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Deprecate passing null to non-nullable arg of internal functionNikita Popov2021-02-111-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge branch 'PHP-8.0'Nikita Popov2021-02-111-1/+1
|\ \ \ | |/ / | | | | | | | | | * PHP-8.0: Don't throw additional Error in require_once if exception already thrown
| * | Don't throw additional Error in require_once if exception already thrownNikita Popov2021-02-111-1/+1
| | | | | | | | | | | | As pointed out in comments on bug #66216.
* | | Use zend_type.ce_cache__ptr for caching class resulution during ↵Dmitry Stogov2021-02-101-39/+59
| | | | | | | | | | | | argument/result type checks
* | | Added Inheritance Cache.Dmitry Stogov2021-02-091-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge branch 'PHP-8.0'Nikita Popov2021-02-091-1/+1
|\ \ \ | |/ / | | | | | | | | | | | | | | | * PHP-8.0: Use E_ERROR to report arginfo/zpp mismatch Make NumberFormatter ctor $pattern nullable Make IntlDateFormatter ctor $pattern nullable
| * | Use E_ERROR to report arginfo/zpp mismatchNikita Popov2021-02-091-1/+1
| | | | | | | | | | | | When E_CORE_ERROR is used, we don't get correct file/line information.
* | | Replace zend_bool uses with boolNikita Popov2021-01-151-29/+29
| | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge branch 'PHP-8.0'Nikita Popov2021-01-121-12/+23
|\ \ \ | |/ / | | | | | | | | | * PHP-8.0: Add support for union types for internal functions
| * | Add support for union types for internal functionsNikita Popov2021-01-121-12/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Remove some INDIRECT handling in VMNikita Popov2021-01-061-28/+4
|/ /
* | Fix bug #80537Nikita Popov2020-12-211-4/+12
| | | | | | | | | | | | | | | | 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.
* | Fix removal of type source during unserializationNikita Popov2020-12-041-0/+1
| | | | | | | | | | | | | | 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.
* | Preallocate stack space for JIT in execute_ex() to eliminate JIT ↵Dmitry Stogov2020-11-301-0/+5
| | | | | | | | prologue/epilogue.
* | Fix signed integer overflowNikita Popov2020-10-301-1/+1
| | | | | | | | Fixes oss-fuzz #26763.
* | Don't allow passing unknown named params to class without ctorNikita Popov2020-10-231-2/+6
| | | | | | | | | | | | See also https://externals.io/message/112083. Closes GH-6364.
* | Add system ID entropy APISammy Kaye Powers2020-09-181-0/+1
| | | | | | | | | | | | 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
* | Remove support for EXT_NOPNikita Popov2020-09-181-2/+1
| | | | | | | | | | | | 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.
* | Fixed bug #80109Nikita Popov2020-09-171-2/+3
| | | | | | | | Skip over leading EXT_NOP, if it exists.
* | Fix uninitialized run-time cache when resolving named param defaultsNikita Popov2020-09-151-0/+4
| | | | | | | | Fixes oss-fuzz #25676.
* | micro-optimizationDmitry Stogov2020-09-151-11/+13
| |
* | Fixed bug #80096Nikita Popov2020-09-141-15/+16
| | | | | | | | | | We shouldn't assume that call->prev_execute_data is NULL here. The value needs to be preserved for call chains.
* | Make argument type error message consistent for variadicsNikita Popov2020-09-111-16/+9
| | | | | | | | | | | | | | | | | | | | If an argument error refers to a variadic argument, we normally do not print the name of the variadic (as it is not referring to an individual argument, but to the collection of all of them). However, this was not the case for the userland argument type error message, which did it's own formatting. Closes GH-6101.
* | JIT for ASSIGN_OBJDmitry Stogov2020-09-101-1/+1
| |
* | Fixed 32-bit JITDmitry Stogov2020-09-101-1/+1
| |
* | Improve error messages mentioning parameters instead of argumentsMáté Kocsis2020-09-091-0/+13
| | | | | | | | Closes GH-5999
* | Don't handle missing value in zend_verify_arg_error()Nikita Popov2020-09-081-21/+17
| | | | | | | | | | This error condition is handled separately, never reaches this function.
* | Accept zend_string instead of zval in zend_compile_stringNikita Popov2020-09-071-1/+3
| |
* | Fix by-ref list assign LIST_W+MAKE_REF separationNikita Popov2020-09-021-72/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Shift the responsibility for emitting MAKE_REF to the list assignment code, to make sure that LIST_W and MAKE_REF are directly adjacent, and there are no opcodes in between that could modify the LIST_W result. Additionally, adjust the zend_wrong_string_offset() code to not perform a loop over opcodes and assert that the next opcode is a relevant one. The VM write-safety model requires this. This is a followup to a07c1f56aac1c0f6c8334760009b678cbf9d6138 and the full fix for oss-fuzz #25352.
* | Merge branch 'PHP-7.4'Nikita Popov2020-09-021-0/+1
|\ \ | |/ | | | | | | * PHP-7.4: Fix infinite loop on string offset during by-ref list assign
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-09-021-0/+1
| |\ | | | | | | | | | | | | * PHP-7.3: Fix infinite loop on string offset during by-ref list assign
| | * Fix infinite loop on string offset during by-ref list assignNikita Popov2020-09-021-0/+1
| | | | | | | | | | | | | | | | | | | | | There is a deeper underlying issue here, in that the opcodes violate VM write-fetch safety, but let's fix the infinite loop first. This fixes oss-fuzz #25352.
* | | Add zend_observer APILevi Morrison2020-09-011-0/+1
| | | | | | | | | | | | | | | | | | | | | Closes GH-5857. Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
* | | Correctly report failure in zend_handle_undef_args()Nikita Popov2020-08-311-0/+1
| | | | | | | | | | | | | | | | | | | | | And do the check before increfing the closure object, otherwise we'd have to release it as well. Fixes oss-fuzz #25313.
* | | Remove unnecessary cache_slot argumentsNikita Popov2020-08-281-19/+12
| | | | | | | | | | | | | | | zend_verify_type_error_common() no longer needs the cache_slot, so drop it there and from all users.
* | | Improve type declarations for Zend APIsGeorge Peter Banyard2020-08-281-25/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Voidification of Zend API which always succeeded Use bool argument types instead of int for boolean arguments Use bool return type for functions which return true/false (1/0) Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics Closes GH-6002
* | | Fix leak in typed reference assignmentNikita Popov2020-08-271-0/+1
| | | | | | | | | | | | | | | We're only creating tmp here to compare against the existing coerced_value. We need to destroy it in all cases.