From: Sammy Kaye Powers Date: Wed, 9 Sep 2020 19:36:51 +0000 (-0700) Subject: Merge branch 'PHP-7.3' into PHP-7.4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b5268265c13b35cba290a5578ff973f797a0620;p=php Merge branch 'PHP-7.3' into PHP-7.4 * PHP-7.3: Fix #79825: opcache.file_cache causes SIGSEGV with custom opcode handlers --- 1b5268265c13b35cba290a5578ff973f797a0620 diff --cc NEWS index 2a3c248d26,a037e2f28a..757d225a4a --- a/NEWS +++ b/NEWS @@@ -22,7 -18,8 +22,9 @@@ PH - OPcache: . Fixed bug #80002 (calc free space for new interned string is wrong). (t-matsuno) + . Fixed bug #80046 (FREE for SWITCH_STRING optimized away). (Nikita) + . Fixed bug #79825 (opcache.file_cache causes SIGSEGV when custom opcode + handlers changed). (SammyK) - PDO: . Fixed bug #80027 (Terrible performance using $query->fetch on queries with diff --cc ext/opcache/ZendAccelerator.c index 6564e4ecc3,3c6a1ae689..25148b0d4a --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@@ -2654,7 -2689,12 +2654,10 @@@ static void accel_globals_ctor(zend_acc static void accel_gen_system_id(void) { PHP_MD5_CTX context; - unsigned char digest[16], c; - char *md5str = ZCG(system_id); - int i; + unsigned char digest[16]; + zend_module_entry *module; + zend_extension *extension; + zend_llist_position pos; PHP_MD5Init(&context); PHP_MD5Update(&context, PHP_VERSION, sizeof(PHP_VERSION)-1); @@@ -2665,8 -2705,28 +2668,21 @@@ PHP_MD5Update(&context, __DATE__, sizeof(__DATE__)-1); PHP_MD5Update(&context, __TIME__, sizeof(__TIME__)-1); } + /* Modules may have changed after restart which can cause dangling pointers from + * custom opcode handlers in the second-level cache files + */ + ZEND_HASH_FOREACH_PTR(&module_registry, module) { + PHP_MD5Update(&context, module->name, strlen(module->name)); + PHP_MD5Update(&context, module->version, strlen(module->version)); + } ZEND_HASH_FOREACH_END(); + extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos); + while (extension) { + PHP_MD5Update(&context, extension->name, strlen(extension->name)); + PHP_MD5Update(&context, extension->version, strlen(extension->version)); + extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos); + } PHP_MD5Final(digest, &context); - for (i = 0; i < 16; i++) { - c = digest[i] >> 4; - c = (c <= 9) ? c + '0' : c - 10 + 'a'; - md5str[i * 2] = c; - c = digest[i] & 0x0f; - c = (c <= 9) ? c + '0' : c - 10 + 'a'; - md5str[(i * 2) + 1] = c; - } + php_hash_bin2hex(accel_system_id, digest, sizeof digest); } #ifdef HAVE_HUGE_CODE_PAGES