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

JIT: misaligned zval passed to ZEND_ADD_ARRAY_ELEMENT handler

Open YuanchengJiang opened this issue 3 weeks ago • 0 comments

Description

The following code:

<?php
set_error_handler(function($errno, $errstr) {
    throw new ErrorException($errstr);
});
class AzureAuthHelper {
    public static function getAzureEnvironment($env) {
        $validEnvs = [
            null => 1, "" => 1, " " => 1, "azure" => 1, "AZURE_CLOUD" => 1,
        ];
        return $validEnvs[strtolower(trim($env))] ?? 1;
    }
}
AzureAuthHelper::getAzureEnvironment("unknown");

Resulted in this output:

Zend/zend_vm_execute.h:7986:4: runtime error: member access within misaligned address 0x7feaa52b2539 for type 'zval' (aka 'struct _zval_struct'), which requires 8 byte alignment
0x7feaa52b2539: note: pointer points here
 00 00 00  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  10 00 00 00 00
              ^ 
    #0 0x6229e71 in ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER Zend/zend_vm_execute.h:7986:4
    #1 0x48812b5c  (/dev/zero (deleted)+0x8000b5c)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Zend/zend_vm_execute.h:7986:4 in 

To reproduce: ./sapi/cli/php -d opcache.enable_cli=1 -d opcache.jit=1235 -d opcache.jit_buffer_size=64M -d opcache.file_update_protection=0 -d opcache.jit_hot_loop=1 -d opcache.jit_hot_func=1 -d opcache.jit_hot_return=1 -d opcache.jit_hot_side_exit=1 test.php

PHP Version

nightly

Operating System

No response

YuanchengJiang avatar Nov 07 '26 09:11 YuanchengJiang