Skip to content

Commit 85df512

Browse files
committed
Fix GH-8065: opcache.consistency_checks > 0 causes segfaults in PHP >= 8.1.5 in fpm context
Disable opcache.consistency_checks. This feature does not work right now and leads to memory leaks and other problems. For analysis and discussion see GH-8065. In GH-10624 it was decided to disable the feature to prevent problems for end users. If end users which to get some consistency guarantees, they can rely on opcache.protect_memory. Closes GH-10798.
1 parent ff62d11 commit 85df512

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ PHP NEWS
1313

1414
- Opcache:
1515
. Fixed build for macOS to cater with pkg-config settings. (David Carlier)
16+
. Fixed bug GH-8065 (opcache.consistency_checks > 0 causes segfaults in
17+
PHP >= 8.1.5 in fpm context). (nielsdos)
1618

1719
- OpenSSL:
1820
. Add missing error checks on file writing functions. (nielsdos)

ext/opcache/tests/gh8065.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
GH-8065: opcache.consistency_checks > 0 causes segfaults in PHP >= 8.1.5 in fpm context
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable_cli=1
7+
opcache.consistency_checks=1
8+
opcache.log_verbosity_level=2
9+
--FILE--
10+
<?php
11+
var_dump(ini_get("opcache.consistency_checks"));
12+
var_dump(ini_set("opcache.consistency_checks", 1));
13+
var_dump(ini_set("opcache.consistency_checks", -1));
14+
var_dump(ini_set("opcache.consistency_checks", 0));
15+
?>
16+
--EXPECTF--
17+
%sWarning opcache.consistency_checks is reset back to 0 because it does not work properly (see GH-8065, GH-10624).
18+
19+
string(1) "0"
20+
%sWarning opcache.consistency_checks is reset back to 0 because it does not work properly (see GH-8065, GH-10624).
21+
22+
bool(false)
23+
%sWarning opcache.consistency_checks is reset back to 0 because it does not work properly (see GH-8065, GH-10624).
24+
25+
bool(false)
26+
string(1) "0"

ext/opcache/zend_accelerator_module.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ static ZEND_INI_MH(OnUpdateMaxWastedPercentage)
108108
return SUCCESS;
109109
}
110110

111+
static ZEND_INI_MH(OnUpdateConsistencyChecks)
112+
{
113+
zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
114+
zend_long consistency_checks = atoi(ZSTR_VAL(new_value));
115+
116+
if (consistency_checks != 0) {
117+
zend_accel_error(ACCEL_LOG_WARNING, "opcache.consistency_checks is reset back to 0 because it does not work properly (see GH-8065, GH-10624).\n");
118+
return FAILURE;
119+
}
120+
*p = 0;
121+
return SUCCESS;
122+
}
123+
111124
static ZEND_INI_MH(OnEnable)
112125
{
113126
if (stage == ZEND_INI_STAGE_STARTUP ||
@@ -242,7 +255,7 @@ ZEND_INI_BEGIN()
242255
STD_PHP_INI_ENTRY("opcache.interned_strings_buffer", "8" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.interned_strings_buffer, zend_accel_globals, accel_globals)
243256
STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "10000", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles, accel_directives.max_accelerated_files, zend_accel_globals, accel_globals)
244257
STD_PHP_INI_ENTRY("opcache.max_wasted_percentage" , "5" , PHP_INI_SYSTEM, OnUpdateMaxWastedPercentage, accel_directives.max_wasted_percentage, zend_accel_globals, accel_globals)
245-
STD_PHP_INI_ENTRY("opcache.consistency_checks" , "0" , PHP_INI_ALL , OnUpdateLong, accel_directives.consistency_checks, zend_accel_globals, accel_globals)
258+
STD_PHP_INI_ENTRY("opcache.consistency_checks" , "0" , PHP_INI_ALL , OnUpdateConsistencyChecks, accel_directives.consistency_checks, zend_accel_globals, accel_globals)
246259
STD_PHP_INI_ENTRY("opcache.force_restart_timeout" , "180" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.force_restart_timeout, zend_accel_globals, accel_globals)
247260
STD_PHP_INI_ENTRY("opcache.revalidate_freq" , "2" , PHP_INI_ALL , OnUpdateLong, accel_directives.revalidate_freq, zend_accel_globals, accel_globals)
248261
STD_PHP_INI_ENTRY("opcache.file_update_protection", "2" , PHP_INI_ALL , OnUpdateLong, accel_directives.file_update_protection, zend_accel_globals, accel_globals)

0 commit comments

Comments
 (0)