From 83f283f5eab3594369dca507588bb8a43817cd3c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 16 Sep 2021 15:47:38 +0200 Subject: [PATCH] Undef result on throwing typed reference assignment --- ext/opcache/jit/zend_jit_x86.dasc | 2 +- ext/opcache/tests/jit/assign_040.phpt | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/jit/assign_040.phpt diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index be9bfd5b053..a0df7bec5c8 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -5995,7 +5995,7 @@ static int zend_jit_assign_to_typed_ref(dasm_State **Dst, | // if (UNEXPECTED(EG(exception) != NULL)) { | MEM_OP2_1_ZTS cmp, aword, executor_globals, exception, 0, r0 | je >8 // END OF zend_jit_assign_to_variable() - | jmp ->exception_handler + | jmp ->exception_handler_undef } else { | jmp >8 } diff --git a/ext/opcache/tests/jit/assign_040.phpt b/ext/opcache/tests/jit/assign_040.phpt new file mode 100644 index 00000000000..0c81506cbef --- /dev/null +++ b/ext/opcache/tests/jit/assign_040.phpt @@ -0,0 +1,27 @@ +--TEST-- +JIT ASSIGN: Typed reference error with return value +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +opcache.protect_memory=1 +--FILE-- +x = ""; + $r =& $test->x; + +($r = $y); +} +try { + test(); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +--EXPECTF-- +Warning: Undefined variable $y in %s on line %d +Cannot assign null to reference held by property Test::$x of type string