Skip to content

Commit 3bc4159

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix file cache run_time_cache unserialization Update ZCSG(map_ptr_last) only if for_shm
2 parents 0d35f8e + 36d5fbb commit 3bc4159

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ext/opcache/zend_file_cache.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,15 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
12821282
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
12831283
} else {
12841284
ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables);
1285-
UNSERIALIZE_PTR(ZEND_MAP_PTR(op_array->run_time_cache));
1285+
if (ZEND_MAP_PTR(op_array->run_time_cache)) {
1286+
if (script->corrupted) {
1287+
/* Not in SHM: Use serialized arena pointer. */
1288+
UNSERIALIZE_PTR(ZEND_MAP_PTR(op_array->run_time_cache));
1289+
} else {
1290+
/* In SHM: Allocate new pointer. */
1291+
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
1292+
}
1293+
}
12861294
}
12871295
}
12881296
}

ext/opcache/zend_persist.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,9 @@ zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script
11381138
} ZEND_HASH_FOREACH_END();
11391139
zend_persist_op_array_ex(&script->script.main_op_array, script);
11401140

1141-
ZCSG(map_ptr_last) = CG(map_ptr_last);
1141+
if (for_shm) {
1142+
ZCSG(map_ptr_last) = CG(map_ptr_last);
1143+
}
11421144

11431145
#ifdef HAVE_JIT
11441146
if (ZCG(jit_enabled) && for_shm) {

0 commit comments

Comments
 (0)