[php-src] Issue #15652: Segmentation fault in the Zend engine (JIT enabled)
| From: | YuanchengJiang | Date: | Fri, 30 Aug 2024 03:14:38 +0000 |
| Subject: | [php-src] Issue #15652: Segmentation fault in the Zend engine (JIT enabled) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247636@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/15652
Author: YuanchengJiang
### Description
The following code:
```php
<?php
class C {
}
trait T {
public function equal(C $type): bool {
return $type instanceof self && $this->value === $type->value;
}
}
class C1 extends C {
use T;
public function __construct(private int $value) {
}
}
class C2 extends C {
use T;
}
$x = new C1(1);
var_dump($x->equal($x));
var_dump($x->equal($x));
$a = new C2("aaa");
var_dump($a->equal($a));
var_dump($a->equal($a));
```
Resulted in this output:
```
=================================================================
==1881556==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x7fcf2b9bdbdc bp 0x7ffc63df4fd0 sp
0x7ffc63df4f30 T0)
==1881556==The signal is caused by a READ memory access.
==1881556==Hint: this fault was caused by a dereference of a high value address (see register values
below). Disassemble the provided pc to learn which register was used.
LLVMSymbolizer: error reading file: No such file or directory
#0 0x7fcf2b9bdbdc (/dev/zero (deleted)+0x8000bdc)
#1 0x5622d9599022 in zend_execute /php-src/Zend/zend_vm_execute.h:63873:2
#2 0x5622da094e08 in zend_execute_script /php-src/Zend/zend.c:1913:3
#3 0x5622d8c684c6 in php_execute_script_ex /php-src/main/main.c:2576:13
#4 0x5622d8c68d68 in php_execute_script /php-src/main/main.c:2616:9
#5 0x5622da0a2c53 in do_cli /php-src/sapi/cli/php_cli.c:935:5
#6 0x5622da09e672 in main /php-src/sapi/cli/php_cli.c:1309:18
#7 0x7fcf7220ad8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/dev/zero (deleted)+0x8000bdc)
==1881556==ABORTING
```
To reproduce:
```
-d "memory_limit=128M" -d "opcache.fast_shutdown=0" -d
"opcache.file_update_protection=0" -d "opcache.revalidate_freq=0" -d
"opcache.jit_hot_loop=1" -d "opcache.jit_hot_func=2" -d
"opcache.jit_hot_return=1" -d "opcache.jit_hot_side_exit=1" -d
"opcache.jit_max_root_traces=100000" -d "opcache.jit_max_side_traces=100000" -d
"opcache.jit_max_exit_counters=100000" -d "opcache.protect_memory=1" -d
"zend.assertions=1" -d "zend.exception_ignore_args=0" -d
"zend.exception_string_param_max_len=15" -d "short_open_tag=0" -d
"extension_dir=/home/phpfuzz/WorkSpace/flowfusion/php-src/modules/" -d
"zend_extension=/home/phpfuzz/WorkSpace/flowfusion/php-src/modules/opcache.so" -d
"session.auto_start=0" -d "opcache.enable=1" -d "opcache.enable_cli=1"
-d "session.gc_maxlifetime=\"1440\"" -d "mysqli.max_links=1" -d
"opcache.jit_buffer_size=1024M" -d "opcache.jit=tracing"
```
### PHP Version
PHP 8.4.0-dev
### Operating System
ubuntu 22.04