[php-src] Issue #20086: Assertion failure in Zend VM during malformed foreach with Error Suppression on Lazy Object (ZEND_BEGIN_SILENCE_SPEC_HANDLER)
| From: | vi3tL0u1s | Date: | Tue, 07 Oct 2025 03:44:36 +0000 |
| Subject: | [php-src] Issue #20086: Assertion failure in Zend VM during malformed foreach with Error Suppression on Lazy Object (ZEND_BEGIN_SILENCE_SPEC_HANDLER) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251006@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20086
Author: vi3tL0u1s
### Description
The following code:
```php
<?php
class C {
public int $a;
public function __construct() {
$this->a= 1;
}
}
$reflector = new ReflectionClass(C::class);
$obj = $reflector->newLazyGhost(function ($obj) {
$obj->__construct();
});
foreach ($obj as $prop => &$value)
$obj = $reflector->newLazyGhost(function ($obj) {
if ($fail) {
} else {
$obj->__const2uct();
}
});
try {
foreach (@obj as $prop => $value) {
}
} catch (Exception $e) {
}
?>
```
Resulted in this output:
```
php: Zend/zend_vm_execute.h:3202: const zend_op *ZEND_BEGIN_SILENCE_SPEC_HANDLER(zend_execute_data
*, const zend_op *): Assertion `!(executor_globals.exception)' failed.
Aborted
```
Commit:
```
6872cf2eef921b9d27fa300ca5a7ad3bc27aee1c
```
Build configuration:
```
CC="clang" CXX="clang++" CFLAGS="-fsanitize=address -g -O0"
CXXFLAGS="-fsanitize=address -g -O0" ./configure --enable-debug --enable-address-sanitizer
--disable-shared --with-pic
```
### PHP Version
```plain
PHP 8.5.0-dev (cli) (built: Oct 7 2025 14:17:27) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies
```
### Operating System
Ubuntu 22.04