summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-08-20 17:56:12 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2019-09-16 16:01:09 +0200
commit20f73d3d8f2f2664288d1e70930f047605bfb44f (patch)
tree1ed24c70e783443b8ce8589c9f6de0bbeacce88b
parent42046c71eef344b139390c1727b885d7a7b83edc (diff)
downloadphp-git-20f73d3d8f2f2664288d1e70930f047605bfb44f.tar.gz
Fix #78429: opcache_compile_file(__FILE__); segfaults
We have to ensure that OPcache has been properly started up when `opcache_compile_file()` is called.
-rw-r--r--NEWS1
-rw-r--r--ext/opcache/tests/bug78429.phpt13
-rw-r--r--ext/opcache/zend_accelerator_module.c5
3 files changed, 19 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 3068f3fad5..bbecf4a3ea 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ PHP NEWS
. Add opcache.preload_user INI directive. (Dmitry)
. Fixed bug #78514 (Preloading segfaults with inherited typed property).
(Nikita)
+ . Fixed bug #78429 (opcache_compile_file(__FILE__); segfaults). (cmb)
- PCRE:
. Fixed bug #78349 (Bundled pcre2 library missing LICENCE file). (Peter Kokot)
diff --git a/ext/opcache/tests/bug78429.phpt b/ext/opcache/tests/bug78429.phpt
new file mode 100644
index 0000000000..d2d1e43cdc
--- /dev/null
+++ b/ext/opcache/tests/bug78429.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #78429 (opcache_compile_file(__FILE__); segfaults)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--INI--
+opcache.enable_cli=0
+--FILE--
+<?php
+var_dump(opcache_compile_file(__FILE__));
+?>
+--EXPECTF--
+Notice: Zend OPcache has not been properly started, can't compile file in %s on line %d
+bool(false)
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index eb5b1c7537..7d04e49f32 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -858,6 +858,11 @@ static ZEND_FUNCTION(opcache_compile_file)
return;
}
+ if (!accel_startup_ok) {
+ zend_error(E_NOTICE, ACCELERATOR_PRODUCT_NAME " has not been properly started, can't compile file");
+ RETURN_FALSE;
+ }
+
zend_stream_init_filename(&handle, script_name);
orig_execute_data = EG(current_execute_data);