]> granicus.if.org Git - php/commitdiff
Bug #80447 (Strange out of memory error when running with JIT)
authorDmitry Stogov <dmitry@zend.com>
Tue, 1 Dec 2020 13:43:05 +0000 (16:43 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 1 Dec 2020 13:43:05 +0000 (16:43 +0300)
NEWS
ext/opcache/jit/zend_jit_trace.c
ext/opcache/tests/jit/bug80447.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index a60ed29a1c3ba83486876e9a0bb1552d4065f241..695ae7408d34fbabe1c18ff9989af7d61364dc15 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ PHP                                                                        NEWS
   . Fixed bug #80377 (Opcache misses executor_globals). (Nikita)
   . Fixed bug #80433 (Unable to disable the use of the AVX command when using
     JIT). (Nikita)
+  . Bug #80447 (Strange out of memory error when running with JIT). (Dmitry)
 
 - OpenSSL:
   . Fixed bug #80368 (OpenSSL extension fails to build against LibreSSL due to
index 19db7c54bb332320eb79bf2a139172c1f61e8884..33658f8e860408fee6759f7a1277ace635a831a1 100644 (file)
@@ -3662,7 +3662,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
 
                zend_jit_label(&dasm_state, 0); /* start of of trace loop */
 
-               if (ra && trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP) {
+               if (ra) {
                        zend_ssa_phi *phi = ssa->blocks[1].phis;
 
                        while (phi) {
diff --git a/ext/opcache/tests/jit/bug80447.phpt b/ext/opcache/tests/jit/bug80447.phpt
new file mode 100644 (file)
index 0000000..b09ff5c
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+Bug #80447 (Strange out of memory error when running with JIT)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+opcache.jit_buffer_size=1M
+opcache.protect_memory=1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function createTree($depth) {
+    if (!$depth) {
+        return [null, null];
+    }
+    $depth--;
+
+    return [
+        createTree($depth),
+        createTree($depth)
+    ];
+}
+
+function checkTree($treeNode) {
+    return 1
+        + ($treeNode[0][0] === null ? 1 : checkTree($treeNode[0]))
+        + ($treeNode[1][0] === null ? 1 : checkTree($treeNode[1]));
+}
+
+$tree = createTree(12);
+var_dump(checkTree($tree));
+--EXPECT--
+int(8191)