Commit 90a7a924 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

spdk_top: check thread ID before invoking pop-up from core pop-up



This is to prevent app crashing when selecting a core with no
threads and invoking threads pop-up. The thread ID is being checked
before threads pop-up is displayed.
(by default this value is set to 0, because valid thread IDs start
from the value of 1).

Fixes #2132

Change-Id: I2285370a41fa087c21f968d13882ad06e6577423
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9363


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChengqiang Meng <chengqiangx.meng@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent e90a98ed
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -2068,7 +2068,7 @@ show_core(uint8_t current_page)
	uint64_t core_number = current_page * g_max_data_rows + g_selected_row;
	struct rpc_core_info *core_info = &g_cores_info[core_number];
	uint64_t threads_count, i;
	uint64_t thread_id;
	uint64_t thread_id = 0;
	uint16_t current_threads_row;
	int c;
	char core_win_title[25];
@@ -2166,9 +2166,13 @@ show_core(uint8_t current_page)
		switch (c) {
		case 10: /* ENTER */
			pthread_mutex_lock(&g_thread_lock);
			if (core_info->threads.threads_count > 0) {
				thread_id = core_info->threads.thread[current_threads_row].id;
			}
			pthread_mutex_unlock(&g_thread_lock);
			if (thread_id != 0) {
				show_single_thread(thread_id);
			}
			break;
		case 27: /* ESC */
			stop_loop = true;