1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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).
This commit is contained in:
Sergei Turchanov
2023-10-11 16:57:18 +10:00
committed by GitHub
parent be64db5939
commit 90f2e7607a

View File

@@ -867,6 +867,8 @@ static void zend_file_cache_serialize_class(zval *zv,
ZEND_MAP_PTR_INIT(ce->static_members_table, NULL);
ZEND_MAP_PTR_INIT(ce->mutable_data, NULL);
ce->inheritance_cache = NULL;
}
static void zend_file_cache_serialize_warnings(