@@ -2655,6 +2655,9 @@ static void accel_gen_system_id(void)
2655
2655
{
2656
2656
PHP_MD5_CTX context ;
2657
2657
unsigned char digest [16 ];
2658
+ zend_module_entry * module ;
2659
+ zend_extension * extension ;
2660
+ zend_llist_position pos ;
2658
2661
2659
2662
PHP_MD5Init (& context );
2660
2663
PHP_MD5Update (& context , PHP_VERSION , sizeof (PHP_VERSION )- 1 );
@@ -2665,6 +2668,19 @@ static void accel_gen_system_id(void)
2665
2668
PHP_MD5Update (& context , __DATE__ , sizeof (__DATE__ )- 1 );
2666
2669
PHP_MD5Update (& context , __TIME__ , sizeof (__TIME__ )- 1 );
2667
2670
}
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
+ }
2668
2684
PHP_MD5Final (digest , & context );
2669
2685
php_hash_bin2hex (accel_system_id , digest , sizeof digest );
2670
2686
}
0 commit comments