Fix #78429: opcache_compile_file(__FILE__); segfaults

We have to ensure that OPcache has been properly started up when
`opcache_compile_file()` is called.
This commit is contained in:
Christoph M. Becker 2019-08-20 17:56:12 +02:00
parent 42046c71ee
commit 20f73d3d8f
3 changed files with 19 additions and 0 deletions

1
NEWS
View file

@ -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)

View file

@ -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)

View file

@ -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);