From b4b0155f6471f79c68b34237677f4ee5cb9c1f64 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 24 Sep 2025 16:48:02 +0100 Subject: [PATCH 1/2] opcache: Fix segfault in function JIT due to NAN to bool warning (#19947) --- ext/opcache/jit/zend_jit_ir.c | 3 ++- ext/opcache/tests/jit/nan_001.phpt | 6 +++--- ext/opcache/tests/jit/nan_002.phpt | 16 ++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 112d09fe165..ec55239953a 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -7742,7 +7742,8 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32 ir_ref is_nan = ir_NE(dval, dval); ir_ref if_val = ir_IF(is_nan); ir_IF_TRUE_cold(if_val); - ir_CALL(IR_VOID, ir_CONST_FC_FUNC(zend_jit_nan_coerced_to_type_warning)); + jit_SET_EX_OPLINE(jit, opline); + ir_CALL(IR_VOID, ir_CONST_FC_FUNC(zend_jit_nan_coerced_to_type_warning)); ir_MERGE_WITH_EMPTY_FALSE(if_val); ref = ir_NE(dval, ir_CONST_DOUBLE(0.0)); diff --git a/ext/opcache/tests/jit/nan_001.phpt b/ext/opcache/tests/jit/nan_001.phpt index c243d7883cf..5765adcf5f7 100644 --- a/ext/opcache/tests/jit/nan_001.phpt +++ b/ext/opcache/tests/jit/nan_001.phpt @@ -14,11 +14,11 @@ for ($i = 0; $i < 3; $i++) { } ?> --EXPECTF-- -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 4 nan is true -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 4 nan is true -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 4 nan is true diff --git a/ext/opcache/tests/jit/nan_002.phpt b/ext/opcache/tests/jit/nan_002.phpt index e77d3c5edd0..8d6ac8e1111 100644 --- a/ext/opcache/tests/jit/nan_002.phpt +++ b/ext/opcache/tests/jit/nan_002.phpt @@ -9,13 +9,13 @@ opcache.protect_memory=1 --EXPECTF-- -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 3 string(1) "1" -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 4 -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 5 bool(true) -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 6 bool(false) string(1) "1" @@ -54,13 +54,13 @@ bool(false) bool(true) -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 10 bool(true) bool(true) bool(false) -Warning: unexpected NAN value was coerced to bool in %s on line %d +Warning: unexpected NAN value was coerced to bool in %s on line 13 bool(true) bool(true) bool(false) From 84ec65c5992045a52643dcb674f0d694be58e3ab Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 24 Sep 2025 16:49:10 +0100 Subject: [PATCH 2/2] Update NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 41f4496d538..27a7d04b633 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.5.0RC2 +- Opcache + . Fixed segfault in function JIT due to NAN to bool warning. (Girgias) 25 Sep 2025, PHP 8.5.0RC1