Skip to content

Commit 20f73d3

Browse files
committed
Fix #78429: opcache_compile_file(__FILE__); segfaults
We have to ensure that OPcache has been properly started up when `opcache_compile_file()` is called.
1 parent 42046c7 commit 20f73d3

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PHP NEWS
1818
. Add opcache.preload_user INI directive. (Dmitry)
1919
. Fixed bug #78514 (Preloading segfaults with inherited typed property).
2020
(Nikita)
21+
. Fixed bug #78429 (opcache_compile_file(__FILE__); segfaults). (cmb)
2122

2223
- PCRE:
2324
. Fixed bug #78349 (Bundled pcre2 library missing LICENCE file). (Peter Kokot)

ext/opcache/tests/bug78429.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #78429 (opcache_compile_file(__FILE__); segfaults)
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--INI--
6+
opcache.enable_cli=0
7+
--FILE--
8+
<?php
9+
var_dump(opcache_compile_file(__FILE__));
10+
?>
11+
--EXPECTF--
12+
Notice: Zend OPcache has not been properly started, can't compile file in %s on line %d
13+
bool(false)

ext/opcache/zend_accelerator_module.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,11 @@ static ZEND_FUNCTION(opcache_compile_file)
858858
return;
859859
}
860860

861+
if (!accel_startup_ok) {
862+
zend_error(E_NOTICE, ACCELERATOR_PRODUCT_NAME " has not been properly started, can't compile file");
863+
RETURN_FALSE;
864+
}
865+
861866
zend_stream_init_filename(&handle, script_name);
862867

863868
orig_execute_data = EG(current_execute_data);

0 commit comments

Comments
 (0)