From f182352e5195c73dc1b44b372c10ce9b23e48cad Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 19 Jul 2024 13:26:22 +0200 Subject: [PATCH 1/2] Compile in opcache without COMPILE_IGNORE_INTERNAL_CLASSES I don't believe there's a reason to compile with this flag. We don't rely on fixed addresses anyway, relying on the signatures of the symbols themselves should be fine. The same goes for file cache itself, as we don't allow loading cache files across PHP versions. --- ext/opcache/ZendAccelerator.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 96a400ee29c3a..c1ce63fcf0891 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1809,7 +1809,6 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl zend_try { orig_compiler_options = CG(compiler_options); CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY; - CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; CG(compiler_options) |= ZEND_COMPILE_DELAYED_BINDING; CG(compiler_options) |= ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION; CG(compiler_options) |= ZEND_COMPILE_IGNORE_OTHER_FILES; From 124558e98f8c6586311049cf794158ee32928577 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 22 Jul 2024 16:09:44 +0200 Subject: [PATCH 2/2] Skip compiling/linking internal classes on Windows and file cache --- ext/opcache/ZendAccelerator.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index c1ce63fcf0891..0bd55d319e31e 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1813,8 +1813,16 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl CG(compiler_options) |= ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION; CG(compiler_options) |= ZEND_COMPILE_IGNORE_OTHER_FILES; CG(compiler_options) |= ZEND_COMPILE_IGNORE_OBSERVER; +#ifdef ZEND_WIN32 + /* On Windows, don't compile with internal classes. Shm may be attached from different + * processes with internal classes living in different addresses. */ + CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; +#endif if (ZCG(accel_directives).file_cache) { CG(compiler_options) |= ZEND_COMPILE_WITH_FILE_CACHE; + /* Don't compile with internal classes for file cache, in case some extension is removed + * later on. We cannot assume it is there in the future. */ + CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; } op_array = *op_array_p = accelerator_orig_compile_file(file_handle, type); CG(compiler_options) = orig_compiler_options;