Skip to content

Commit f1ce44d

Browse files
committed
Fix static variables in main script with file cache
If the script will be cached in SHM (!corrupted), then we cannot allocate the static variables on the arena. Instead do the same thing we do during normal persistence and allocate a map ptr slot.
1 parent 7159907 commit f1ce44d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ext/opcache/zend_file_cache.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,15 +1244,17 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
12441244
zend_persistent_script *script,
12451245
void *buf)
12461246
{
1247-
if (!(script->corrupted)
1248-
&& op_array != &script->script.main_op_array) {
1249-
op_array->fn_flags |= ZEND_ACC_IMMUTABLE;
1247+
if (!script->corrupted) {
1248+
if (op_array != &script->script.main_op_array) {
1249+
op_array->fn_flags |= ZEND_ACC_IMMUTABLE;
1250+
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
1251+
} else {
1252+
ZEND_ASSERT(!(op_array->fn_flags & ZEND_ACC_IMMUTABLE));
1253+
ZEND_MAP_PTR_INIT(op_array->run_time_cache, NULL);
1254+
}
12501255
if (op_array->static_variables) {
12511256
ZEND_MAP_PTR_NEW(op_array->static_variables_ptr);
1252-
} else {
1253-
ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, NULL);
12541257
}
1255-
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
12561258
} else {
12571259
op_array->fn_flags &= ~ZEND_ACC_IMMUTABLE;
12581260
if (op_array->static_variables) {

0 commit comments

Comments
 (0)