[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] [php-src] master: Fixed codegeneration for NOT
From:       Dmitry Stogov <noreply () php ! net>
Date:       2023-10-31 5:48:39
Message-ID: vSw5P5MzyrH26bBUMRTLBoGH56eOlPxZwRT3ynlo () main ! php ! net
[Download RAW message or body]

Author: Dmitry Stogov (dstogov)
Date: 2023-10-31T08:34:14+03:00

Commit: https://github.com/php/php-src/commit/ed37ab9d1418db341121164603db47fee6f1bb9c
Raw diff: https://github.com/php/php-src/commit/ed37ab9d1418db341121164603db47fee6f1bb9c.diff

Fixed codegeneration for NOT

Fixes oss-fuzz #63749

Changed paths:
  A  ext/opcache/tests/jit/not_003.phpt
  M  ext/opcache/jit/zend_jit_ir.c


Diff:

diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index 2ae4ec0959f0..3a3591d59d4a 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -3864,7 +3864,8 @@ static void zend_jit_type_check_undef(zend_jit_ctx  *jit,
                                       uint32_t       var,
                                       const zend_op *opline,
                                       bool           check_exception,
-                                      bool           in_cold_path)
+                                      bool           in_cold_path,
+                                      bool           undef_result)
 {
 	ir_ref if_def = ir_IF(type);
 
@@ -3878,7 +3879,11 @@ static void zend_jit_type_check_undef(zend_jit_ctx  *jit,
 	}
 	ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(var));
 	if (check_exception) {
-		zend_jit_check_exception(jit);
+		if (undef_result) {
+			zend_jit_check_exception_undef_result(jit, opline);
+		} else {
+			zend_jit_check_exception(jit);
+		}
 	}
 	ir_MERGE_WITH_EMPTY_TRUE(if_def);
 }
@@ -7301,7 +7306,7 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32
 				zend_jit_type_check_undef(jit,
 					type,
 					opline->op1.var,
-					opline, 1, 0);
+					opline, 1, 0, 1);
 			}
 			if (set_bool) {
 				jit_set_Z_TYPE_INFO(jit, res_addr, set_bool_not ? IS_TRUE : IS_FALSE);
@@ -12201,12 +12206,12 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx       *jit,
 				jit_SET_EX_OPLINE(jit, opline);
 				if (opline->opcode != ZEND_FETCH_DIM_IS && (op1_info & MAY_BE_UNDEF)) {
 					may_throw = 1;
-					zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op1_addr), opline->op1.var, NULL, 0, 1);
+					zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op1_addr), opline->op1.var, NULL, 0, 1, 0);
 				}
 
 				if (op2_info & MAY_BE_UNDEF) {
 					may_throw = 1;
-					zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op2_addr), opline->op2.var, NULL, 0, 1);
+					zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op2_addr), opline->op2.var, NULL, 0, 1, 0);
 				}
 			}
 
diff --git a/ext/opcache/tests/jit/not_003.phpt b/ext/opcache/tests/jit/not_003.phpt
new file mode 100644
index 000000000000..39cb9588054f
--- /dev/null
+++ b/ext/opcache/tests/jit/not_003.phpt
@@ -0,0 +1,18 @@
+--TEST--
+JIT NOT: 003
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+opcache.jit_buffer_size=1M
+opcache.protect_memory=1
+--FILE--
+<?php
+set_error_handler(function(){y;}) . !$y;
+?>
+--EXPECTF--
+Fatal error: Uncaught Error: Undefined constant "y" in %snot_003.php:2
+Stack trace:
+#0 %snot_003.php(2): {closure}(2, '%s', '%s', 2)
+#1 {main}
+  thrown in %snot_003.php on line 2
\ No newline at end of file

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic