From e088ecb395914dd997450b8fd1f09035255dc202 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Thu, 30 Oct 2025 13:06:55 +0100 Subject: [PATCH 1/2] Remove CE cache from non-interned file cache strings --- ext/opcache/zend_file_cache.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index edcaf689ab7f1..d580c90f315e4 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -134,18 +134,21 @@ static int zend_file_cache_flock(int fd, int type) (ptr) = (void*)((char*)buf + (size_t)(ptr)); \ } \ } while (0) + #define SERIALIZE_STR(ptr) do { \ if (ptr) { \ if (IS_ACCEL_INTERNED(ptr)) { \ (ptr) = zend_file_cache_serialize_interned((zend_string*)(ptr), info); \ } else { \ ZEND_ASSERT(IS_UNSERIALIZED(ptr)); \ + (ptr) = (void*)((char*)(ptr) - (char*)script->mem); \ + zend_string *__new_str = (zend_string*)((char*)buf + (uintptr_t)(ptr)); \ /* script->corrupted shows if the script in SHM or not */ \ if (EXPECTED(script->corrupted)) { \ - GC_ADD_FLAGS(ptr, IS_STR_INTERNED); \ - GC_DEL_FLAGS(ptr, IS_STR_PERMANENT); \ + GC_ADD_FLAGS(__new_str, IS_STR_INTERNED); \ + GC_DEL_FLAGS(__new_str, IS_STR_PERMANENT); \ } \ - (ptr) = (void*)((char*)(ptr) - (char*)script->mem); \ + GC_DEL_FLAGS(__new_str, IS_STR_CLASS_NAME_MAP_PTR); \ } \ } \ } while (0) From 1113b3c5d256d8af104ca8806dbbc8f07ba02e0f Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Wed, 5 Nov 2025 13:00:31 +0100 Subject: [PATCH 2/2] Move all flag updates to UNSERIALIZE_STR() --- ext/opcache/zend_file_cache.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index d580c90f315e4..defc3b9942aee 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -142,13 +142,6 @@ static int zend_file_cache_flock(int fd, int type) } else { \ ZEND_ASSERT(IS_UNSERIALIZED(ptr)); \ (ptr) = (void*)((char*)(ptr) - (char*)script->mem); \ - zend_string *__new_str = (zend_string*)((char*)buf + (uintptr_t)(ptr)); \ - /* script->corrupted shows if the script in SHM or not */ \ - if (EXPECTED(script->corrupted)) { \ - GC_ADD_FLAGS(__new_str, IS_STR_INTERNED); \ - GC_DEL_FLAGS(__new_str, IS_STR_PERMANENT); \ - } \ - GC_DEL_FLAGS(__new_str, IS_STR_CLASS_NAME_MAP_PTR); \ } \ } \ } while (0) @@ -166,6 +159,7 @@ static int zend_file_cache_flock(int fd, int type) GC_ADD_FLAGS(ptr, IS_STR_INTERNED); \ GC_DEL_FLAGS(ptr, IS_STR_PERMANENT); \ } \ + GC_DEL_FLAGS(ptr, IS_STR_CLASS_NAME_MAP_PTR); \ } \ } \ } while (0)