Skip to content

Commit b4b0155

Browse files
authored
opcache: Fix segfault in function JIT due to NAN to bool warning (php#19947)
1 parent 0202124 commit b4b0155

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7742,7 +7742,8 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32
77427742
ir_ref is_nan = ir_NE(dval, dval);
77437743
ir_ref if_val = ir_IF(is_nan);
77447744
ir_IF_TRUE_cold(if_val);
7745-
ir_CALL(IR_VOID, ir_CONST_FC_FUNC(zend_jit_nan_coerced_to_type_warning));
7745+
jit_SET_EX_OPLINE(jit, opline);
7746+
ir_CALL(IR_VOID, ir_CONST_FC_FUNC(zend_jit_nan_coerced_to_type_warning));
77467747
ir_MERGE_WITH_EMPTY_FALSE(if_val);
77477748

77487749
ref = ir_NE(dval, ir_CONST_DOUBLE(0.0));

ext/opcache/tests/jit/nan_001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ for ($i = 0; $i < 3; $i++) {
1414
}
1515
?>
1616
--EXPECTF--
17-
Warning: unexpected NAN value was coerced to bool in %s on line %d
17+
Warning: unexpected NAN value was coerced to bool in %s on line 4
1818
nan is true
1919

20-
Warning: unexpected NAN value was coerced to bool in %s on line %d
20+
Warning: unexpected NAN value was coerced to bool in %s on line 4
2121
nan is true
2222

23-
Warning: unexpected NAN value was coerced to bool in %s on line %d
23+
Warning: unexpected NAN value was coerced to bool in %s on line 4
2424
nan is true

ext/opcache/tests/jit/nan_002.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ opcache.protect_memory=1
99
<?php
1010
function test(float $a) {
1111
if ($a) var_dump("1");
12-
if (!$a) var_dump("2");
12+
if (!$a) var_dump("2");
1313
var_dump((bool) $a);
1414
var_dump(!$a);
1515
echo "\n";
1616
}
1717
function test1(float $a, bool $b) {
18-
var_dump($a && $b); //JMPNZ_EX
18+
var_dump($a && $b); //JMPNZ_EX
1919
}
2020
function test2(float $a, bool $b) {
2121
var_dump($a || $b); // JMPZ_EX
@@ -34,15 +34,15 @@ test2(1.0, false);
3434
test2(0.0, false);
3535
?>
3636
--EXPECTF--
37-
Warning: unexpected NAN value was coerced to bool in %s on line %d
37+
Warning: unexpected NAN value was coerced to bool in %s on line 3
3838
string(1) "1"
3939

40-
Warning: unexpected NAN value was coerced to bool in %s on line %d
40+
Warning: unexpected NAN value was coerced to bool in %s on line 4
4141

42-
Warning: unexpected NAN value was coerced to bool in %s on line %d
42+
Warning: unexpected NAN value was coerced to bool in %s on line 5
4343
bool(true)
4444

45-
Warning: unexpected NAN value was coerced to bool in %s on line %d
45+
Warning: unexpected NAN value was coerced to bool in %s on line 6
4646
bool(false)
4747

4848
string(1) "1"
@@ -54,13 +54,13 @@ bool(false)
5454
bool(true)
5555

5656

57-
Warning: unexpected NAN value was coerced to bool in %s on line %d
57+
Warning: unexpected NAN value was coerced to bool in %s on line 10
5858
bool(true)
5959
bool(true)
6060
bool(false)
6161

6262

63-
Warning: unexpected NAN value was coerced to bool in %s on line %d
63+
Warning: unexpected NAN value was coerced to bool in %s on line 13
6464
bool(true)
6565
bool(true)
6666
bool(false)

0 commit comments

Comments
 (0)