php-src icon indicating copy to clipboard operation
php-src copied to clipboard

misaligned zval read in ReflectionProperty::isReadable() on internal virtual property

Open YuanchengJiang opened this issue 3 weeks ago • 0 comments

Description

The following code:

<?php
$rp = new ReflectionProperty(DOMDocument::class, "nodeName");
var_dump($rp->isReadable(null, new DOMDocument));

Resulted in this output:

Zend/zend_types.h:697:13: runtime error: member access within misaligned address 0x7fcbe7e4c437 for type 'const zval' (aka 'const struct _zval_struct'), which requires 8 byte alignment
0x7fcbe7e4c437: note: pointer points here
<memory cannot be printed>
    #0 0x3b6c462 in zval_get_type Zend/zend_types.h:697:13
    #1 0x3c69a58 in zim_ReflectionProperty_isReadable ext/reflection/php_reflection.c:6754:7
    #2 0x61eac15 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER Zend/zend_vm_execute.h:2152:4
    #3 0x5fabacc in execute_ex Zend/zend_vm_execute.h:110621:12
    #4 0x5fad941 in zend_execute Zend/zend_vm_execute.h:116059:2
    #5 0x6b9a226 in zend_execute_script Zend/zend.c:1980:3
    #6 0x550f6d6 in php_execute_script_ex main/main.c:2636:13
    #7 0x5510358 in php_execute_script main/main.c:2676:9
    #8 0x6bab555 in do_cli sapi/cli/php_cli.c:943:5
    #9 0x6ba61e7 in do_php_cli sapi/cli/php_cli.c:1360:18
    #10 0x6ba4851 in main sapi/cli/php_cli_main.c:18:9
    #11 0x7fcaedf8bd8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #12 0x7fcaedf8be3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #13 0x606504 in _start (sapi/cli/php+0x606504)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Zend/zend_types.h:697:13 in 

To reproduce: ./sapi/cli/php test.php

PHP Version

nightly

Operating System

No response

YuanchengJiang avatar Nov 07 '26 09:11 YuanchengJiang