[php-src] Issue #15834: Segfault with hook "simple get" cache slot and minimal JIT
| From: | nielsdos | Date: | Wed, 11 Sep 2024 07:12:29 +0000 |
| Subject: | [php-src] Issue #15834: Segfault with hook "simple get" cache slot and minimal JIT | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247751@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/15834
Author: nielsdos
### Description
Originally posted in https://github.com/php/php-src/pull/15819#issuecomment-2342032634
The following code:
```php
<?php
class A {
private $_prop;
public $prop {
get => $this->_prop;
}
}
for ($i=0;$i<2;$i++)
echo (new A)->prop;
```
using
opcache.jit=1101
Resulted in this output:
```
Segfault
```
But I expected this output instead:
```
No segfault
```
I analysed this and this is a different bug related to a cache slot optimization.
As far as I understand, this happens for when the cache slot satisfies the
ZEND_IS_PROPERTY_HOOK_SIMPLE_GET condition. Then we set up a function call frame and
re-enter the VM to execute the hook function:
https://github.com/php/php-src/blob/7c2204c9158bb33163c638dc8286b516121288ef/Zend/zend_vm_def.h#L2094-L2126
This seems incompatible with how the minimal JIT works, getting the property will be skipped.
Indeed if we get rid of ZEND_SET_PROPERTY_HOOK_SIMPLE_GET in
zend_object_handlers.c or go to a higher optimization level the problem disappears.
I'm not sure yet how to solve that.
### PHP Version
master
### Operating System
Linux