From 9d94f1550d1a90cb05584839df47b541bb1ad9a8 Mon Sep 17 00:00:00 2001 From: Eli Qiao Date: Tue, 18 Mar 2014 09:36:27 +0800 Subject: [PATCH] Fix segment fault when numa nodes not sequential or contiguous Signed-off-by: Eli Qiao --- numastat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/numastat.c b/numastat.c index 8232396..42f8531 100644 --- a/numastat.c +++ b/numastat.c @@ -1053,7 +1053,11 @@ void show_process_info() { } else { tmp_row = header_rows + pid_ix; } - int tmp_col = header_cols + node_num; + // Don't assume nodes are sequential or contiguous. + // Need to find correct tmp_col from node_ix_map + int i = 0; + while(node_ix_map[i++] != node_num); + int tmp_col = header_cols + i - 1; double_addto(&table, tmp_row, tmp_col, value); double_addto(&table, tmp_row, total_col_ix, value); double_addto(&table, total_row_ix, tmp_col, value); -- 1.8.3.1