Skip to content

Commit b7fa526

Browse files
committed
Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1)
1 parent 8162c3d commit b7fa526

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PHP NEWS
1111

1212
- Opcache:
1313
. Fixed bug #80786 (PHP crash using JIT). (Nikita)
14+
. Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1). (Dmitry)
1415

1516
- Session:
1617
. Fixed bug #80774 (session_name() problem with backslash). (cmb)

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4329,12 +4329,17 @@ static int zend_jit_math_long_long(dasm_State **Dst,
43294329
}
43304330

43314331
do {
4332-
if ((Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op1_addr)) == 1) ||
4333-
(Z_MODE(op2_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op2_addr)) == 1)) {
4332+
if ((sizeof(void*) == 8 || Z_MODE(res_addr) != IS_REG) &&
4333+
((Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op1_addr)) == 1) ||
4334+
(Z_MODE(op2_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op2_addr)) == 1))) {
43344335
if (opcode == ZEND_ADD) {
43354336
|.if X64
43364337
| mov64 rax, 0x43e0000000000000
4337-
| SET_ZVAL_LVAL res_addr, rax
4338+
if (Z_MODE(res_addr) == IS_REG) {
4339+
| movd xmm(Z_REG(res_addr)-ZREG_XMM0), rax
4340+
} else {
4341+
| SET_ZVAL_LVAL res_addr, rax
4342+
}
43384343
|.else
43394344
| SET_ZVAL_LVAL res_addr, 0
43404345
| SET_ZVAL_W2 res_addr, 0x41e00000
@@ -4343,7 +4348,11 @@ static int zend_jit_math_long_long(dasm_State **Dst,
43434348
} else if (opcode == ZEND_SUB) {
43444349
|.if X64
43454350
| mov64 rax, 0xc3e0000000000000
4346-
| SET_ZVAL_LVAL res_addr, rax
4351+
if (Z_MODE(res_addr) == IS_REG) {
4352+
| movd xmm(Z_REG(res_addr)-ZREG_XMM0), rax
4353+
} else {
4354+
| SET_ZVAL_LVAL res_addr, rax
4355+
}
43474356
|.else
43484357
| SET_ZVAL_LVAL res_addr, 0x00200000
43494358
| SET_ZVAL_W2 res_addr, 0xc1e00000

ext/opcache/tests/jit/bug80782.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit=tracing
8+
opcache.jit_buffer_size=1M
9+
opcache.protect_memory=1
10+
--SKIPIF--
11+
<?php require_once('skipif.inc'); ?>
12+
--FILE--
13+
<?php
14+
define('LONG_MIN', PHP_INT_MIN);
15+
var_dump(LONG_MIN-1);
16+
?>
17+
--EXPECTF--
18+
float(%s)

0 commit comments

Comments
 (0)