Skip to content

Commit 4366f22

Browse files
committed
Fix #78202: Opcache stats for cache hits are capped at 32bit NUM
We use the proper format specifiers now.
1 parent 102c64e commit 4366f22

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PHP NEWS
1111

1212
- OPcache:
1313
. Fixed #78189 (file cache strips last character of uname hash). (cmb)
14+
. Fixed #78202 (Opcache stats for cache hits are capped at 32bit NUM). (cmb)
1415

1516
27 Jun 2019, PHP 7.2.20
1617

ext/opcache/zend_accelerator_module.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -482,33 +482,33 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
482482
char buf[32];
483483
php_info_print_table_row(2, "Startup", "OK");
484484
php_info_print_table_row(2, "Shared memory model", zend_accel_get_shared_model());
485-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, (zend_ulong)ZCSG(hits));
485+
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(hits));
486486
php_info_print_table_row(2, "Cache hits", buf);
487-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
487+
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
488488
php_info_print_table_row(2, "Cache misses", buf);
489489
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory));
490490
php_info_print_table_row(2, "Used memory", buf);
491-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, zend_shared_alloc_get_free_memory());
491+
snprintf(buf, sizeof(buf), "%zu", zend_shared_alloc_get_free_memory());
492492
php_info_print_table_row(2, "Free memory", buf);
493-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZSMMG(wasted_shared_memory));
493+
snprintf(buf, sizeof(buf), "%zu", ZSMMG(wasted_shared_memory));
494494
php_info_print_table_row(2, "Wasted memory", buf);
495495
if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) {
496-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
496+
snprintf(buf, sizeof(buf), "%td", ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
497497
php_info_print_table_row(2, "Interned Strings Used memory", buf);
498-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
498+
snprintf(buf, sizeof(buf), "%td", ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
499499
php_info_print_table_row(2, "Interned Strings Free memory", buf);
500500
}
501-
snprintf(buf, sizeof(buf), "%d", ZCSG(hash).num_direct_entries);
501+
snprintf(buf, sizeof(buf), "%" PRIu32, ZCSG(hash).num_direct_entries);
502502
php_info_print_table_row(2, "Cached scripts", buf);
503-
snprintf(buf, sizeof(buf), "%d", ZCSG(hash).num_entries);
503+
snprintf(buf, sizeof(buf), "%" PRIu32, ZCSG(hash).num_entries);
504504
php_info_print_table_row(2, "Cached keys", buf);
505-
snprintf(buf, sizeof(buf), "%d", ZCSG(hash).max_num_entries);
505+
snprintf(buf, sizeof(buf), "%" PRIu32, ZCSG(hash).max_num_entries);
506506
php_info_print_table_row(2, "Max keys", buf);
507-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(oom_restarts));
507+
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(oom_restarts));
508508
php_info_print_table_row(2, "OOM restarts", buf);
509-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(hash_restarts));
509+
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(hash_restarts));
510510
php_info_print_table_row(2, "Hash keys restarts", buf);
511-
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(manual_restarts));
511+
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(manual_restarts));
512512
php_info_print_table_row(2, "Manual restarts", buf);
513513
}
514514
}

0 commit comments

Comments
 (0)