Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT)
authorDmitry Stogov <dmitry@zend.com>
Mon, 1 Mar 2021 20:57:20 +0000 (23:57 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 1 Mar 2021 20:57:20 +0000 (23:57 +0300)
ext/opcache/tests/jit/bug80802.phpt [new file with mode: 0644]
ext/spl/spl_array.c

diff --git a/ext/opcache/tests/jit/bug80802.phpt b/ext/opcache/tests/jit/bug80802.phpt
new file mode 100644 (file)
index 0000000..89a116c
--- /dev/null
@@ -0,0 +1,49 @@
+--TEST--
+Bug #80802: zend_jit_fetch_indirect_var assert failure with tracing JIT
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit_buffer_size=1M
+opcache.jit=tracing
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+abstract class AsyncTask{
+        private static $threadLocalStorage = null;
+
+        protected function storeLocal(string $key, $complexData) : void{
+                if(self::$threadLocalStorage === null){
+                        self::$threadLocalStorage = new \ArrayObject();
+                }
+                self::$threadLocalStorage[spl_object_id($this)][$key] = $complexData;
+        }
+
+        final public function __destruct(){
+                $this->reallyDestruct();
+                if(self::$threadLocalStorage !== null and isset(self::$threadLocalStorage[$h = spl_object_id($this)])){
+                        unset(self::$threadLocalStorage[$h]);
+                        if(self::$threadLocalStorage->count() === 0){
+                                self::$threadLocalStorage = null;
+                        }
+                }
+        }
+
+        protected function reallyDestruct() : void{
+
+        }
+}
+
+class Task extends AsyncTask{
+        public function __construct(){
+                $this->storeLocal("thing1", new stdClass);
+        }
+}
+
+for($i = 0; $i < 10000; ++$i){
+        new Task;
+}
+echo "OK\n";
+?>
+--EXPECT--
+OK
index 20a9d9e3da50e09b130a26c5b48bef04ec635f0c..76e9fbae2be93947bf25c029dca4eda8aee37be6 100644 (file)
@@ -365,7 +365,7 @@ num_index:
                                        zend_error(E_WARNING, "Undefined array key " ZEND_LONG_FMT, index);
                                case BP_VAR_W: {
                                    zval value;
-                                       ZVAL_UNDEF(&value);
+                                       ZVAL_NULL(&value);
                                        retval = zend_hash_index_update(ht, index, &value);
                           }
                        }