From 121727ff4ca322124ba578ba9490cce08dc1f178 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 25 Jun 2019 09:56:33 +0200 Subject: [PATCH 1/6] Fix #78202: Opcache stats for cache hits are capped at 32bit NUM Since the respective variables are declared as `zend_ulong` we have to also format them as such. --- ext/opcache/zend_accelerator_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index d74b2ac644f5d..6f647557f4e84 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -482,9 +482,9 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) char buf[32]; php_info_print_table_row(2, "Startup", "OK"); php_info_print_table_row(2, "Shared memory model", zend_accel_get_shared_model()); - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, (zend_ulong)ZCSG(hits)); + snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(hits)); php_info_print_table_row(2, "Cache hits", buf); - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses)); + snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses)); php_info_print_table_row(2, "Cache misses", buf); snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory)); php_info_print_table_row(2, "Used memory", buf); From 2c75fc7af8d82b6b444719fa14b29678a7142754 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 25 Jun 2019 10:15:52 +0200 Subject: [PATCH 2/6] Use the proper format for size_t values --- ext/opcache/zend_accelerator_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 6f647557f4e84..6f493641c82ab 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -488,9 +488,9 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_row(2, "Cache misses", buf); snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory)); php_info_print_table_row(2, "Used memory", buf); - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, zend_shared_alloc_get_free_memory()); + snprintf(buf, sizeof(buf), "zu", zend_shared_alloc_get_free_memory()); php_info_print_table_row(2, "Free memory", buf); - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZSMMG(wasted_shared_memory)); + snprintf(buf, sizeof(buf), "zu", ZSMMG(wasted_shared_memory)); php_info_print_table_row(2, "Wasted memory", buf); if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) { snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(interned_strings_top) - ZCSG(interned_strings_start)); From f2b196e76c13ef95afcb057295a0ecb3f957edde Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 25 Jun 2019 10:21:58 +0200 Subject: [PATCH 3/6] Use proper format for `uint32_t` values --- ext/opcache/zend_accelerator_module.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 6f493641c82ab..b7de3d06953fe 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -498,11 +498,11 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(interned_strings_end) - ZCSG(interned_strings_top)); php_info_print_table_row(2, "Interned Strings Free memory", buf); } - snprintf(buf, sizeof(buf), "%d", ZCSG(hash).num_direct_entries); + snprintf(buf, sizeof(buf), "%" PRIu32, ZCSG(hash).num_direct_entries); php_info_print_table_row(2, "Cached scripts", buf); - snprintf(buf, sizeof(buf), "%d", ZCSG(hash).num_entries); + snprintf(buf, sizeof(buf), "%" PRIu32, ZCSG(hash).num_entries); php_info_print_table_row(2, "Cached keys", buf); - snprintf(buf, sizeof(buf), "%d", ZCSG(hash).max_num_entries); + snprintf(buf, sizeof(buf), "%" PRIu32, ZCSG(hash).max_num_entries); php_info_print_table_row(2, "Max keys", buf); snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(oom_restarts)); php_info_print_table_row(2, "OOM restarts", buf); From 0c67dad80cb2516a313e158323c5f5ed655f09c2 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 25 Jun 2019 10:28:12 +0200 Subject: [PATCH 4/6] Fix "zu" specifiers --- ext/opcache/zend_accelerator_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index b7de3d06953fe..77b9fd029b777 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -488,9 +488,9 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_row(2, "Cache misses", buf); snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory)); php_info_print_table_row(2, "Used memory", buf); - snprintf(buf, sizeof(buf), "zu", zend_shared_alloc_get_free_memory()); + snprintf(buf, sizeof(buf), "%zu", zend_shared_alloc_get_free_memory()); php_info_print_table_row(2, "Free memory", buf); - snprintf(buf, sizeof(buf), "zu", ZSMMG(wasted_shared_memory)); + snprintf(buf, sizeof(buf), "%zu", ZSMMG(wasted_shared_memory)); php_info_print_table_row(2, "Wasted memory", buf); if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) { snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(interned_strings_top) - ZCSG(interned_strings_start)); From a29ae4a14a2c7e5937e73e854d263205ea3849a8 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 25 Jun 2019 10:31:38 +0200 Subject: [PATCH 5/6] Use proper format for `ptrdiff_t` --- ext/opcache/zend_accelerator_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 77b9fd029b777..c58c2c9f6cd56 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -493,9 +493,9 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) snprintf(buf, sizeof(buf), "%zu", ZSMMG(wasted_shared_memory)); php_info_print_table_row(2, "Wasted memory", buf); if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) { - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(interned_strings_top) - ZCSG(interned_strings_start)); + snprintf(buf, sizeof(buf), "%td", ZCSG(interned_strings_top) - ZCSG(interned_strings_start)); php_info_print_table_row(2, "Interned Strings Used memory", buf); - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(interned_strings_end) - ZCSG(interned_strings_top)); + snprintf(buf, sizeof(buf), "%td", ZCSG(interned_strings_end) - ZCSG(interned_strings_top)); php_info_print_table_row(2, "Interned Strings Free memory", buf); } snprintf(buf, sizeof(buf), "%" PRIu32, ZCSG(hash).num_direct_entries); From ed7246da42e2df00b539846983f0d200b46b4957 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 25 Jun 2019 10:33:22 +0200 Subject: [PATCH 6/6] Fix more `zend_ulong` specifiers --- ext/opcache/zend_accelerator_module.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index c58c2c9f6cd56..ef80ffa630ae1 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -504,11 +504,11 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_row(2, "Cached keys", buf); snprintf(buf, sizeof(buf), "%" PRIu32, ZCSG(hash).max_num_entries); php_info_print_table_row(2, "Max keys", buf); - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(oom_restarts)); + snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(oom_restarts)); php_info_print_table_row(2, "OOM restarts", buf); - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(hash_restarts)); + snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(hash_restarts)); php_info_print_table_row(2, "Hash keys restarts", buf); - snprintf(buf, sizeof(buf), ZEND_LONG_FMT, ZCSG(manual_restarts)); + snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(manual_restarts)); php_info_print_table_row(2, "Manual restarts", buf); } }