Skip to content

Commit 36d5fbb

Browse files
committed
Fix file cache run_time_cache unserialization
If the script was serialized as file_cache_only (thus non-immutable) and then gets unserialized into SHM, we need to allocate a new run_time_cache slot and can't use the serialized arena pointer.
1 parent e576d34 commit 36d5fbb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ext/opcache/zend_file_cache.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,15 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
12371237
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
12381238
} else {
12391239
ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables);
1240-
UNSERIALIZE_PTR(ZEND_MAP_PTR(op_array->run_time_cache));
1240+
if (ZEND_MAP_PTR(op_array->run_time_cache)) {
1241+
if (script->corrupted) {
1242+
/* Not in SHM: Use serialized arena pointer. */
1243+
UNSERIALIZE_PTR(ZEND_MAP_PTR(op_array->run_time_cache));
1244+
} else {
1245+
/* In SHM: Allocate new pointer. */
1246+
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
1247+
}
1248+
}
12411249
}
12421250
}
12431251
}

0 commit comments

Comments
 (0)