Skip to content

Commit 3375374

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79825: opcache.file_cache causes SIGSEGV with custom opcode handlers
2 parents 3861cb8 + 1b52682 commit 3375374

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,9 @@ static void accel_gen_system_id(void)
27162716
{
27172717
PHP_MD5_CTX context;
27182718
unsigned char digest[16];
2719+
zend_module_entry *module;
2720+
zend_extension *extension;
2721+
zend_llist_position pos;
27192722

27202723
PHP_MD5Init(&context);
27212724
PHP_MD5Update(&context, PHP_VERSION, sizeof(PHP_VERSION)-1);
@@ -2726,6 +2729,19 @@ static void accel_gen_system_id(void)
27262729
PHP_MD5Update(&context, __DATE__, sizeof(__DATE__)-1);
27272730
PHP_MD5Update(&context, __TIME__, sizeof(__TIME__)-1);
27282731
}
2732+
/* Modules may have changed after restart which can cause dangling pointers from
2733+
* custom opcode handlers in the second-level cache files
2734+
*/
2735+
ZEND_HASH_FOREACH_PTR(&module_registry, module) {
2736+
PHP_MD5Update(&context, module->name, strlen(module->name));
2737+
PHP_MD5Update(&context, module->version, strlen(module->version));
2738+
} ZEND_HASH_FOREACH_END();
2739+
extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos);
2740+
while (extension) {
2741+
PHP_MD5Update(&context, extension->name, strlen(extension->name));
2742+
PHP_MD5Update(&context, extension->version, strlen(extension->version));
2743+
extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos);
2744+
}
27292745
PHP_MD5Final(digest, &context);
27302746
php_hash_bin2hex(accel_system_id, digest, sizeof digest);
27312747
}

0 commit comments

Comments
 (0)