]> granicus.if.org Git - php/commitdiff
Fixed JIT for TYPE_CHECK opcode (exception handling in case of undefined argument)
authorDmitry Stogov <dmitry@zend.com>
Tue, 12 Nov 2019 07:42:29 +0000 (10:42 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 12 Nov 2019 07:42:29 +0000 (10:42 +0300)
ext/opcache/jit/zend_jit_x86.dasc
ext/opcache/tests/jit/type_check_001.phpt [new file with mode: 0644]

index 6f1913a1a1e0db3605b44ee178cfef4eee88751e..dc40387c1b2f6020f41817e3e6fb244251e98a82 100644 (file)
@@ -8028,6 +8028,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, int b, i
                |       SAVE_VALID_OPLINE opline
                |       mov FCARG1d, opline->op1.var
                |       EXT_CALL zend_jit_undefined_op_helper, r0
+               zend_jit_check_exception_undef_result(Dst, opline);
                if (opline->extended_value & MAY_BE_NULL) {
                        if (!zend_jit_smart_true(Dst, opline, b, op_array, ssa, (op1_info & (MAY_BE_ANY|MAY_BE_REF)) != 0, smart_branch)) {
                                return 0;
diff --git a/ext/opcache/tests/jit/type_check_001.phpt b/ext/opcache/tests/jit/type_check_001.phpt
new file mode 100644 (file)
index 0000000..c8ef2cf
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+JIT TYPE_CHECK: 001 exception handling
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+opcache.jit_buffer_size=1M
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+set_error_handler(function($no, $msg) {
+       throw new Exception($msg);
+});
+
+try {
+       if (!is_scalar($a)) {
+               undefined_function('Null');
+       }
+} catch (Exception $e) {
+       echo "Exception: " . $e->getMessage() . "\n";
+}
+?>
+--EXPECT--
+Exception: Undefined variable: a