numastat: fix bad column calculation in show_process_info
PATCH 1/1 numastat: fix bad column calculation in show_process_info
When system has non contiguous numa node number, double_add writing in bad area in table struct.
[root@ibm-p8-03-lp1 numactl]# numastat qemu-kvm
Per-node process memory usage (in MBs) for PID 33331 (qemu-kvm)
Node 0 Node 3 Total
--------------- --------------- ---------------
Huge 0.00 0.00 0.00
Heap 0.00 0.00 23.75
24 0.00 0.00 0.62
1 0.00 0.00 47.62
---------------- --------------- --------------- ---------------
Total 0.00 0.00 72.00
*** Error in `numastat': double free or corruption (!prev): 0x00000100077301c0 ***
======= Backtrace: =========
/lib64/libc.so.6(cfree+0x44c)[0x3fff8df24dec]
numastat[0x100025b0]
numastat[0x1000444c]
numastat[0x100014c4]
/lib64/libc.so.6(+0x24700)[0x3fff8deb4700]
/lib64/libc.so.6(__libc_start_main+0xc4)[0x3fff8deb48f4]
======= Memory map: ========
10000000-10010000 r-xp 00000000 fd:00 16136 /usr/bin/numastat
10010000-10020000 r--p 00000000 fd:00 16136 /usr/bin/numastat
10020000-10030000 rw-p 00010000 fd:00 16136 /usr/bin/numastat
10007730000-10007760000 rw-p 00000000 00:00 0 [heap]
3fff8de80000-3fff8de90000 rw-p 00000000 00:00 0
3fff8de90000-3fff8e050000 r-xp 00000000 fd:00 33616617 /usr/lib64/libc-2.17.so
3fff8e050000-3fff8e060000 r--p 001b0000 fd:00 33616617 /usr/lib64/libc-2.17.so
3fff8e060000-3fff8e070000 rw-p 001c0000 fd:00 33616617 /usr/lib64/libc-2.17.so
3fff8e070000-3fff8e080000 rw-p 00000000 00:00 0
3fff8e080000-3fff8e0a0000 r-xp 00000000 00:00 0 [vdso]
3fff8e0a0000-3fff8e0d0000 r-xp 00000000 fd:00 35349218 /usr/lib64/ld-2.17.so
3fff8e0d0000-3fff8e0e0000 r--p 00020000 fd:00 35349218 /usr/lib64/ld-2.17.so
3fff8e0e0000-3fff8e0f0000 rw-p 00030000 fd:00 35349218 /usr/lib64/ld-2.17.so
3fffeeef0000-3fffeef20000 rw-p 00000000 00:00 0 [stack]
(SIGABRT)
After fix:
[root@ibm-p8-03-lp1 numactl]# numastat qemu-kvm
Per-node process memory usage (in MBs) for PID 33331 (qemu-kvm)
Node 0 Node 3 Total
--------------- --------------- ---------------
Huge 0.00 0.00 0.00
Heap 0.00 23.75 23.75
Stack 0.00 0.62 0.62
Private 0.00 47.62 47.62
---------------- --------------- --------------- ---------------
Total 0.00 72.00 72.00
[root@ibm-p8-03-lp1 numactl]#Signed-off-by Petr Oros <[email protected]>
--- numastat.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
numastat.c +7 -1
@@ -1054,7 +1054,13 @@ void show_process_info() { }else { tmp_row = header_rows + pid_ix; } -int tmp_col = header_cols + node_num; +int tmp_col = header_cols; +for (int ix =0 ; (ix < num_nodes); ix++) { +if (node_ix_map[ix] == node_num) { + tmp_col = tmp_col + ix; +break ; + } + }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);
Signature · 1 line
2.13.0
Quoted 1 line · Petr Oros
When system has non contiguous numa node number,
double_addwriting in bad area in table struct.
Should be already covered in
commit b608687037d873ad82d6318f231b3d6612e8601d
Author: Seeteena Thoufeek <[email protected]> Date: Wed Dec 21 12:48:11 2016 +0530
Segment fault when numa nodes not sequential or contiguous
in https://github.com/numactl/numactl
Please check.
-Andi