Skip to content

Commit 1b52682

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

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ PHP NEWS
2323
. Fixed bug #80002 (calc free space for new interned string is wrong).
2424
(t-matsuno)
2525
. Fixed bug #80046 (FREE for SWITCH_STRING optimized away). (Nikita)
26+
. Fixed bug #79825 (opcache.file_cache causes SIGSEGV when custom opcode
27+
handlers changed). (SammyK)
2628

2729
- PDO:
2830
. Fixed bug #80027 (Terrible performance using $query->fetch on queries with

ext/opcache/ZendAccelerator.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,6 +2655,9 @@ static void accel_gen_system_id(void)
26552655
{
26562656
PHP_MD5_CTX context;
26572657
unsigned char digest[16];
2658+
zend_module_entry *module;
2659+
zend_extension *extension;
2660+
zend_llist_position pos;
26582661

26592662
PHP_MD5Init(&context);
26602663
PHP_MD5Update(&context, PHP_VERSION, sizeof(PHP_VERSION)-1);
@@ -2665,6 +2668,19 @@ static void accel_gen_system_id(void)
26652668
PHP_MD5Update(&context, __DATE__, sizeof(__DATE__)-1);
26662669
PHP_MD5Update(&context, __TIME__, sizeof(__TIME__)-1);
26672670
}
2671+
/* Modules may have changed after restart which can cause dangling pointers from
2672+
* custom opcode handlers in the second-level cache files
2673+
*/
2674+
ZEND_HASH_FOREACH_PTR(&module_registry, module) {
2675+
PHP_MD5Update(&context, module->name, strlen(module->name));
2676+
PHP_MD5Update(&context, module->version, strlen(module->version));
2677+
} ZEND_HASH_FOREACH_END();
2678+
extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos);
2679+
while (extension) {
2680+
PHP_MD5Update(&context, extension->name, strlen(extension->name));
2681+
PHP_MD5Update(&context, extension->version, strlen(extension->version));
2682+
extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos);
2683+
}
26682684
PHP_MD5Final(digest, &context);
26692685
php_hash_bin2hex(accel_system_id, digest, sizeof digest);
26702686
}

0 commit comments

Comments
 (0)