From e80660dc17ab46524bcf945eda4530583d477f32 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 20 Aug 2019 17:56:12 +0200 Subject: [PATCH] Fix #78429: opcache_compile_file(__FILE__); segfaults We have to ensure that OPcache has been properly started up when `opcache_compile_file()` is called. --- ext/opcache/tests/bug78429.phpt | 13 +++++++++++++ ext/opcache/zend_accelerator_module.c | 5 +++++ 2 files changed, 18 insertions(+) create mode 100644 ext/opcache/tests/bug78429.phpt diff --git a/ext/opcache/tests/bug78429.phpt b/ext/opcache/tests/bug78429.phpt new file mode 100644 index 0000000000000..d2d1e43cdc0e2 --- /dev/null +++ b/ext/opcache/tests/bug78429.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #78429 (opcache_compile_file(__FILE__); segfaults) +--SKIPIF-- + +--INI-- +opcache.enable_cli=0 +--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 25f3cc5b81a9f..6000355fe18b7 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -852,6 +852,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);