@@ -2716,6 +2716,9 @@ static void accel_gen_system_id(void)
2716
2716
{
2717
2717
PHP_MD5_CTX context ;
2718
2718
unsigned char digest [16 ];
2719
+ zend_module_entry * module ;
2720
+ zend_extension * extension ;
2721
+ zend_llist_position pos ;
2719
2722
2720
2723
PHP_MD5Init (& context );
2721
2724
PHP_MD5Update (& context , PHP_VERSION , sizeof (PHP_VERSION )- 1 );
@@ -2726,6 +2729,19 @@ static void accel_gen_system_id(void)
2726
2729
PHP_MD5Update (& context , __DATE__ , sizeof (__DATE__ )- 1 );
2727
2730
PHP_MD5Update (& context , __TIME__ , sizeof (__TIME__ )- 1 );
2728
2731
}
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
+ }
2729
2745
PHP_MD5Final (digest , & context );
2730
2746
php_hash_bin2hex (accel_system_id , digest , sizeof digest );
2731
2747
}
0 commit comments