From 7ea417e5a3d68d39a79e444c8b527add2bd52605 Mon Sep 17 00:00:00 2001 From: Maciej Szwed Date: Wed, 10 Jun 2020 10:21:48 +0200 Subject: [PATCH] spdk_top: Issue crash when pollers number changes Root cause: We hit assert because we don't find previous poller run counter. This happens when new poller is created but 'last_run_counter' is not being initialized for that poller. Solution: Force running store_last_run_counter() (which inits last_run_counter) inside copy_pollers() by simulating page change by changing value of g_last_page and calling refresh_pollers_tab() again. Fixes issue #1436 Signed-off-by: Maciej Szwed Change-Id: I983154ba1f7a46a92cba41c83691f71be8ab40b0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2847 Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- app/spdk_top/spdk_top.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index 0b7c9269a..8531cd32a 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -1083,6 +1083,8 @@ refresh_pollers_tab(uint8_t current_page) g_last_page = current_page; } + max_pages = (count + g_max_data_rows - 1) / g_max_data_rows; + /* Clear screen if number of pollers changed */ if (g_last_pollers_count != count) { for (i = TABS_DATA_START_ROW; i < g_data_win_size; i++) { @@ -1092,9 +1094,13 @@ refresh_pollers_tab(uint8_t current_page) } g_last_pollers_count = count; - } - max_pages = (count + g_max_data_rows - 1) / g_max_data_rows; + /* We need to run store_last_run_counter() again, so the easiest way is to call this function + * again with changed g_last_page value */ + g_last_page = 0xF; + refresh_pollers_tab(current_page); + return max_pages; + } /* Timed pollers can switch their possition on a list because of how they work. * Let's sort them by name first so that they won't switch on data refresh */