php / php-src

The PHP Interpreter
https://www.php.net
Other
37.93k stars 7.72k forks source link

Member access within misaligned address in ext/opcache/jit/zend_jit.c #15490

Closed YuanchengJiang closed 2 weeks ago

YuanchengJiang commented 3 weeks ago

Description

The following code:

<?php

for ($i = 0; $i < 100; $i++) {
    UniqueListLast::bar();
}
for ($i = 0; $i < 100; $i++) {
    new UniqueListLast();
}
?>

Resulted in this output:

/php-src/ext/opcache/jit/zend_jit.c:2788:21: runtime error: member access within misaligned address 0x000500000004 for type 'zend_call_info' (aka 'struct _zend_call_info'), which requires 8 byte alignment
0x000500000004: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/opcache/jit/zend_jit.c:2788:21

To reproduce:

php -d "extension_dir=/php-src/modules/" -d "zend_extension=/php-src/modules/opcache.so" -d "opcache.preload=./gh8461-007.inc" -d "opcache.enable=1" -d "opcache.enable_cli=1" -d "opcache.jit=1235" ./test.php

gh8461-007.inc is at ext/opcache/tests/jit/gh8461-007.inc

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

cmb69 commented 3 weeks ago

See also #15481.