Skip to content

Commit 90f2e76

Browse files
authored
Reset inheritance_cache pointer of zend_class_entry upon serialization (#12401)
to opcache filecache. Usually, when a class is being loaded, a dependency tracking is performed after the call to zend_file_cache_script_store. But sometimes, when opcache cache is empty and there are many simultaneous outstanding requests for compilation, some classes do have their inheritance_cache initialized before the call to zend_file_cache_script_store, and in that case this pointer is serialized as-is. And when such a class is loaded from opcache filecache this pointer also loaded as-is, and now it points to some random location in memory. This causes segfaults occuring when traversing inheritance_cache of such classes. We need to reset inheritance_cache pointer of zend_class_entry upon serialization. This should have been done anyway since it is a sensible strategy to sanitize any memory pointer upon serialization (either by calling SERIALIZE_x macros or setting to NULL or any other deterministic value).
1 parent be64db5 commit 90f2e76

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ext/opcache/zend_file_cache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,8 @@ static void zend_file_cache_serialize_class(zval *zv,
867867

868868
ZEND_MAP_PTR_INIT(ce->static_members_table, NULL);
869869
ZEND_MAP_PTR_INIT(ce->mutable_data, NULL);
870+
871+
ce->inheritance_cache = NULL;
870872
}
871873

872874
static void zend_file_cache_serialize_warnings(

0 commit comments

Comments
 (0)