[php-src] Issue #14387: Crash when stack walking in destructor of yielded from values during Generator->throw()
| From: | bwoebi | Date: | Fri, 31 May 2024 10:54:15 +0000 |
| Subject: | [php-src] Issue #14387: Crash when stack walking in destructor of yielded from values during Generator->throw() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246994@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14387
Author: bwoebi
### Description
The following code (https://3v4l.org/QeJLV):
```php
<?php
$gen = (function() {
yield from [null, new class { function __destruct() { throw new Exception; } }];
})();
function foo($gen) {
$gen->valid();
}
foo($gen);
function spray() {}
spray(...range(1, 20));
$gen->throw(new Error);
```
Resulted in segmentation fault.
But I expected this output instead:
```
Fatal error: Uncaught Exception in /in/QeJLV:4
Stack trace:
#0 /in/QeJLV(4): class@anonymous->__destruct()
#1 [internal function]: {closure}()
#2 /in/QeJLV(15): Generator->throw(Object(Error))
#3 {main}
Next Error in /in/QeJLV:15
Stack trace:
#0 {main}
thrown in /in/QeJLV on line 15
```
### PHP Version
PHP 8.0.19-8.3.7
### Operating System
_No response_