summaryrefslogtreecommitdiff
path: root/Zend/zend_generators.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix throwing of yield from related exceptions into generatorNikita Popov2020-09-021-1/+1
| | | | | | | | | | | Use the general zend_generator_throw_exception() helper for this. Otherwise we don't handle the off-by-one opline correctly (should we maybe just stop doing that?) This is a followup to ad750c3bb6e7b48384c6265eb9d3bcf5b4000652, which fixed a different yield from exception handling problem that happened to show up in the same test case from oss-fuzz #25321. Now both issues should be fixed.
* Fix handling of exception if valid() during yield fromNikita Popov2020-08-311-0/+3
| | | | Fixes oss-fuzz #25296.
* Remove bogus generator iterator dtorNikita Popov2020-06-301-4/+0
| | | | | | | | | | | Fixes a use-after-free encountered in Symfony's SecurityBundle. I don't have a reproducer for this, and believe the issue can only occur if we leak an iterator (the leak is a separate issue). We should not free the generator iterator here, because we do not own it. The code that fetched the iterator is responsible for releasing it. In the rare case where we do hit this code-path, we cause a use-after-free.
* Rethrow generator exception even without active stack frameNikita Popov2019-12-181-3/+4
| | | | | | | Finally blocks in generators may be invoked during shutdown, in which case we don't have a stack frame. Similar to what zend_call_function does, we still need to rethrow these exceptions, otherwise they will be hidden (and leak).
* Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-10-281-8/+12
|\ | | | | | | | | * PHP-7.2: Fix bug #78752
| * Fix bug #78752Nikita Popov2019-10-281-8/+12
| | | | | | | | | | | | | | | | | | NULL out the execute_data before destroying it, otherwise GC may trigger while the execute_data is partially destroyed, resulting in double-frees. The handling of call stack unfreezing is a bit awkward because it's a ZEND_API function, so we can't change the signature.
* | Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-08-141-2/+2
|\ \ | |/
| * Fixed bug #78412Nikita Popov2019-08-141-2/+2
| | | | | | | | | | $this should only be included in the generator GC buffer, if it will be released on destruction.
* | Check for NULL GC type in objects_store_delNikita Popov2019-03-011-4/+2
| | | | | | | | | | | | | | | | | | | | | | This might happen if OBJ_RELEASE is used on an object that was already released by GC. Specific cases of this issue were previously fixed in ffaee27478a9cb338e40edeb5acf233f9cb67111 and 72104d2b6ecbbabd18de15f10739be5ce3dc9ce0, however the issue still affects 3rd-party extensions using OBJ_RELEASE. The whole GC type NULL + OBJ_IS_VALID + IS_FREE_CALLED system seems overly complicated and can probably be simplified in 7.4.
* | Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2018-09-281-0/+36
|\ \ | |/
| * Merge branch 'PHP-7.1' into PHP-7.2Nikita Popov2018-09-281-0/+36
| |\
| | * Fixed bug #76946Nikita Popov2018-09-281-0/+36
| | |
* | | Remove unused Git attributes identPeter Kokot2018-07-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The $Id$ keywords were used in Subversion where they can be substituted with filename, last revision number change, last changed date, and last user who changed it. In Git this functionality is different and can be done with Git attribute ident. These need to be defined manually for each file in the .gitattributes file and are afterwards replaced with 40-character hexadecimal blob object name which is based only on the particular file contents. This patch simplifies handling of $Id$ keywords by removing them since they are not used anymore.
* | | Improved user iterator implementation to reduce zend_class_entry memory ↵Dmitry Stogov2018-07-121-1/+0
| | | | | | | | | | | | consumption and avoid race condition during resolving/caching of user iterator functions of internal classes in ZTS build.
* | | Uze ZVAL_COPY_DEREF() instead of ZVAL_DEREF() and ZVAL_COPY()Dmitry Stogov2018-07-091-10/+5
| | |
* | | supplemental fix for bug #76427Xinchen Hui2018-06-121-1/+2
| | | | | | | | | | | | | | | | | | | | | there are two parts to make this problem visible , the first is our new gc new freeing zvals in an opposite direction(compare to 7.2) the second is zend_object_store_del doesn't check IS_VALID since 7.3 (using assertion instead)
* | | Fixed bug #76427 (Segfault in zend_objects_store_put)Xinchen Hui2018-06-111-1/+2
| | |
* | | Export standard object handlers, to avoid indirect accessDmitry Stogov2018-05-311-1/+1
| | |
* | | Remove return types from some magic method in protosGabriel Caruso2018-03-091-1/+1
| | | | | | | | | | | | __construct, __destruct, __wakeup does not have return types defined.
* | | Access extra data stored in zval through macrosDmitry Stogov2018-01-231-1/+1
| | |
* | | Removed recursive callDmitry Stogov2018-01-161-1/+0
| | |
* | | Merge branch 'PHP-7.2'Nikita Popov2018-01-131-7/+7
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.1' into PHP-7.2Nikita Popov2018-01-131-7/+7
| |\ \ | | |/
| | * Fix generator GC if yield from parent chain does not reach rootNikita Popov2018-01-131-7/+7
| | | | | | | | | | | | | | | | | | | | | Parents may be unlinked while another generator sharing part of the chain is running. As such, we cannot assume that the parent chain goes all the way to the root. Instead walk backwards from root to leaf, like we also do during destruction.
* | | Merge branch 'PHP-7.2'Nikita Popov2018-01-121-2/+4
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.1' into PHP-7.2Nikita Popov2018-01-121-2/+4
| |\ \ | | |/
| | * Try to fix yield from GC issuesNikita Popov2018-01-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | Make sure we always update root and parent references before releasing the old root object. This fixes some crashes under aggressive cycle collection, so hopefully this will also fix bug #75351.
* | | Merge branch 'PHP-7.2'Nikita Popov2018-01-121-1/+2
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.1' into PHP-7.2Nikita Popov2018-01-121-1/+2
| |\ \ | | |/
| | * Fixed bug #75396Nikita Popov2018-01-121-1/+2
| | | | | | | | | | | | | | | | | | Do not run finally blocks in generators on unclean shutdown (e.g. caused by exit). This is consistent with how finally blocks outside of generators behave.
| | * year++Xinchen Hui2018-01-021-1/+1
| | |
| * | year++Xinchen Hui2018-01-021-1/+1
| | |
* | | Simplify non-linear generator yield from treeNikita Popov2018-01-121-73/+32
| | | | | | | | | | | | | | | | | | | | | | | | Remove special handling for 2-4 children. Now the three possible cases are no children, one child, or many children (HT). The non-linear (many children) case is extremely rare, so there is no point in trying to optimize it.
* | | Avoid duplicate addition of generators in yield from treeNikita Popov2018-01-121-2/+0
| | |
* | | Use ZEND_CLOSURE_OBJECT() macro to resolve closure op_array to closure ↵Dmitry Stogov2018-01-111-2/+3
| | | | | | | | | | | | object through address calculation, instead of op_array->prototype reuse. (reapply 781e1573afdc7c336b3577ceabc9c65cafea17e8, now it should be OK).
* | | Revert "Use ZEND_CLOSURE_OBJECT() macro to resolve closure op_array to ↵Dmitry Stogov2018-01-111-3/+2
| | | | | | | | | | | | | | | | | | closure object through address calculation, instead of op_array->prototype reuse." (this patch is incomplete or wrong) This reverts commit 781e1573afdc7c336b3577ceabc9c65cafea17e8.
* | | Use ZEND_CLOSURE_OBJECT() macro to resolve closure op_array to closure ↵Dmitry Stogov2018-01-111-2/+3
| | | | | | | | | | | | object through address calculation, instead of op_array->prototype reuse.
* | | year++Xinchen Hui2018-01-021-1/+1
| | |
* | | Move zend_object_iterator_funcs structures into read-only data segmentDmitry Stogov2017-12-141-1/+1
| | |
* | | Remove some unnecessary duplicationsNikita Popov2017-10-301-4/+4
| | |
* | | Encapsulate reference-counting primitives.Dmitry Stogov2017-10-271-3/+3
|/ / | | | | | | | | | | Prohibit direct update of GC_REFCOUNT(), GC_SET_REFCOUNT(), GC_ADDREF() and GC_DELREF() shoukf be instead. Added mactros to validate reference-counting (disabled for now). These macros are going to be used to eliminate race-condintions during reference-counting on data shared between threads.
* | Merge branch 'PHP-7.1' into PHP-7.2Bob Weinand2017-07-221-4/+2
|\ \ | |/
| * Merge branch 'PHP-7.0' into PHP-7.1Bob Weinand2017-07-221-4/+2
| |\
| | * Fixed bug #74954 (null deref and segfault in zend_generator_resume())Bob Weinand2017-07-221-4/+2
| | |
| | * Update copyright headers to 2017Sammy Kaye Powers2017-01-041-1/+1
| | |
* | | further sync for vim mode linesAnatol Belski2017-07-041-0/+2
| | |
* | | Merge branch 'PHP-7.1'Bob Weinand2017-05-171-1/+1
|\ \ \ | |/ /
| * | Fixed bug #74606 (Segfault within try/catch/finally nesting in Generators)Bob Weinand2017-05-171-1/+1
| | | | | | | | | | | | Thanks to Nikita for pointing out the error source.
| * | Update copyright headers to 2017Sammy Kaye Powers2017-01-041-1/+1
| | |
* | | Update copyright headers to 2017Sammy Kaye Powers2017-01-021-1/+1
| | |