summaryrefslogtreecommitdiff
path: root/Zend/zend_generators.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'PHP-7.4' into PHP-8.0Nikita Popov2020-11-181-0/+10
|\ | | | | | | | | * PHP-7.4: Short-circuit get_gc for currently running generator
| * Short-circuit get_gc for currently running generatorNikita Popov2020-11-181-0/+10
| |
* | Simplify and fix generator tree managementNikita Popov2020-10-221-247/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes a number of related changes to the generator tree management, that should hopefully make it easier to understand, more robust and faster for the common linear-chain case. Fixes https://bugs.php.net/bug.php?id=80240, which was the original motivation here. * Generators now only add a ref to their direct parent. * Nodes only store their children, not their leafs, which avoids any need for leaf updating. This means it's no longer possible to fetch the child for a certain leaf, which is something we only needed in one place (update_current). If multi-children nodes are involved, this will require doing a walk in the other direction (from leaf to root). It does not affect the common case of single-child nodes. * The root/leaf pointers are now seen as a pair. One leaf generator can point to the current root. If a different leaf generator is used, we'll move the root pointer over to that one. Again, this is a cache to make the common linear chain case fast, trees may need to scan up the parent link. Closes GH-6344.
* | Run tidyNikita Popov2020-09-181-1/+1
| | | | | | | | | | This should fix most of the remaining issues with tabs and spaces being mixed in tests.
* | Cleanup observer API and add JIT supportDmitry Stogov2020-09-181-11/+2
| |
* | Fix use-after-free with yield from in yield_from_multi_tree_single_nodes.phptBob Weinand2020-09-141-0/+2
| | | | | | | | Prevent release of generator children during destruction
* | Fix crashes with unproper cleaning of repeated yield fromBob Weinand2020-09-141-11/+91
| | | | | | | | Closes GH-6130
* | Don't allow dynamic properties on generatorsNikita Popov2020-09-071-1/+1
| | | | | | | | | | Noticed this because we leak those properties in GC. This was never intended to be allowed.
* | Merge branch 'PHP-7.4'Nikita Popov2020-09-021-1/+1
|\ \ | |/ | | | | | | * PHP-7.4: Fix throwing of yield from related exceptions into generator
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-09-021-1/+1
| |\ | | | | | | | | | | | | * PHP-7.3: Fix throwing of yield from related exceptions into generator
| | * 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.
* | | Assert there are children in zend_generator_get_child()Nikita Popov2020-09-011-3/+2
| | |
* | | Add zend_observer APILevi Morrison2020-09-011-1/+20
| | | | | | | | | | | | | | | | | | | | | Closes GH-5857. Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
* | | Merge branch 'PHP-7.4'Nikita Popov2020-08-311-0/+3
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix handling of exception if valid() during yield from
| * | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-08-311-0/+3
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Fix handling of exception if valid() during yield from
| | * Fix handling of exception if valid() during yield fromNikita Popov2020-08-311-0/+3
| | | | | | | | | | | | Fixes oss-fuzz #25296.
* | | Improve type declarations for Zend APIsGeorge Peter Banyard2020-08-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Fixed bug #79927Nikita Popov2020-08-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | We need to unset the AT_FIRST_YIELD flag when yielding from an array as well. In the interest of being conservative, I'm applying this only to PHP 8.
* | | Implement named parametersNikita Popov2020-07-311-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From an engine perspective, named parameters mainly add three concepts: * The SEND_* opcodes now accept a CONST op2, which is the argument name. For now, it is looked up by linear scan and runtime cached. * This may leave UNDEF arguments on the stack. To avoid having to deal with them in other places, a CHECK_UNDEF_ARGS opcode is used to either replace them with defaults, or error. * For variadic functions, EX(extra_named_params) are collected and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS. RFC: https://wiki.php.net/rfc/named_params Closes GH-5357.
* | | Remove proto comments from C filesMax Semenik2020-07-061-16/+8
| | | | | | | | | | | | Closes GH-5758
* | | Add iterator get_gc function for generatorsNikita Popov2020-07-011-1/+9
| | | | | | | | | | | | Closes GH-5787.
* | | Add get_gc handle for object iteratorsNikita Popov2020-07-011-1/+2
| | | | | | | | | | | | Optional handler with the same semantics as the object handler.
* | | Remove generator iterator memberNikita Popov2020-06-301-4/+1
| | | | | | | | | | | | | | | This is probably a leftover from the PHP 5 implementation, where the iterator was embedded directly in the generator.
* | | Merge branch 'PHP-7.4'Nikita Popov2020-06-301-4/+0
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Remove bogus generator iterator dtor
| * | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-06-301-4/+0
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Remove bogus generator iterator dtor
| | * 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.
* | | Tracing JIT support for include() and generatorsDmitry Stogov2020-06-291-0/+3
| | |
* | | Add ZVAL_OBJ_COPY macroNikita Popov2020-06-171-2/+1
| | | | | | | | | | | | | | | For the common ZVAL_OBJ + GC_ADDREF pattern. This mirrors the existing ZVAL_STR_COPY API.
* | | Merge branch 'PHP-7.4'Nikita Popov2020-06-081-0/+1
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fixed bug #79657
| * | Fixed bug #79657Nikita Popov2020-06-081-0/+1
| | | | | | | | | | | | | | | Throwing an exception should count as an initialization for this purpose.
* | | Merge branch 'PHP-7.4'Nikita Popov2020-05-151-0/+1
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fixed bug #79600
| * | Fixed bug #79600Nikita Popov2020-05-151-0/+1
| | | | | | | | | | | | Missed unsetting of DO_INIT in one case.
* | | Fix miscellaneous typos in code comments/var namesTyson Andre2020-05-011-1/+1
| | | | | | | | | | | | Closes GH-5501
* | | Add helper APIs for get_gc implementationsNikita Popov2020-04-271-76/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_gc() implementations that need to explore heterogeneous data currently work by computing how many GC entries they need, allocating a buffer for that and storing it on the object. This is inefficient and wastes memory, because the buffer is retained after the GC run. This commit adds an API for a single global GC buffer, which can be reused by get_gc implementations (as only one get_gc call is ever active at the same time). The GC buffer will automatically grow during the GC run and be discarded at the end.
* | | Generate method entries from stubs for Zend classesMáté Kocsis2020-04-261-13/+1
| | | | | | | | | | | | Closes GH-5459
* | | Merge branch 'PHP-7.4'Nikita Popov2020-04-091-2/+4
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fixed bug #78434
| * | Fixed bug #78434Nikita Popov2020-04-091-2/+4
| | | | | | | | | | | | | | | | | | The DO_INIT flag, which will skip the first resume on a primed generator, should always be set when starting to yield from a new generator, not only when the yield from happens during priming.
* | | Convert zend_parse_parameters_none() to fast ZPPMáté Kocsis2020-01-031-18/+6
| | | | | | | | | | | | I've done the conversion in those extensions where fast ZPP is predominant.
* | | Use RETURN_THROWS() during ZPP in main, sapi, win32, and ZendMáté Kocsis2019-12-301-6/+6
| | |
* | | Merge branch 'PHP-7.4'Nikita Popov2019-12-201-23/+44
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix leak when generator closed during yield in finally
| * | Fix leak when generator closed during yield in finallyNikita Popov2019-12-201-23/+44
| | | | | | | | | | | | | | | In this case we need to free any pending exceptions or return values that will be discarded.
* | | Merge branch 'PHP-7.4'Nikita Popov2019-12-181-3/+4
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Rethrow generator exception even without active stack frame
| * | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-12-181-3/+4
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Rethrow generator exception even without active stack frame
| | * 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.4'Nikita Popov2019-10-281-8/+12
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fix bug #78752
| * | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-10-281-8/+12
| |\ \ | | |/ | | | | | | | | | * PHP-7.3: Fix bug #78752
| | * 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.
* | | | Add Zend class/interface arginfo stubsChristoph M. Becker2019-10-151-20/+10
| | | | | | | | | | | | | | | | | | | | | | | | We also change `Generator::throw()` to expect a `Throwable` in the first place, and we now throw a TypeError instead of returning `false` from `Exception::getTraceAsString()`.
* | | | Merge branch 'PHP-7.4'Nikita Popov2019-08-141-2/+2
|\ \ \ \ | |/ / /