Segfault on ppc64
Jaroslav Skarvada
PowerTOP crashes on ppc64 machine with 1 idle state, reproducer:
# powertop -t 1 --html
Parameters of the machine are attached.
It seems the problem is caused by the report_display_cpu_cstates() function from the src/cpu/cpu.cpp file.
On https://github.com/fenrus75/powertop/blob/e8765b5475b22b7a2b6e9e8a031c68a268a0b0b3/src/cpu/cpu.cpp#L494
it allocates table 2x1, but the table should be 2x2 (header + 1 state), so it
later crashes on
https://github.com/fenrus75/powertop/blob/e8765b5475b22b7a2b6e9e8a031c68a268a0b0b3/src/cpu/cpu.cpp#L580
where it tries to fill the table.
Unfortunately, the whole reporting code is quite unclear, so I am not sure how to correctly fix it and not break anything else. The attached patch fixes the problem for me, but it can have side-effects - feel free to propose better fix
thanks & regards
Jaroslav
Machine parameters:
# cpupower idle-info CPUidle driver: pseries_idle CPUidle governor: menu analyzing CPU 0:
Number of idle states: 1
Available idle states: Shared Cede
Shared Cede:
Flags/Description: Shared Cede
Latency: 0
Usage: 1188350
Duration: 14152220333
# cat /proc/cpuinfo processor : 0 cpu : POWER8E (raw), altivec supported clock : 3425.000000MHz revision : 2.1 (pvr 004b 0201)
processor : 1
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 2
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 3
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 4
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 5
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 6
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
processor : 7
cpu : POWER8E (raw), altivec supported
clock : 3425.000000MHz
revision : 2.1 (pvr 004b 0201)
timebase : 512000000
platform : pSeries
model : IBM pSeries (emulated by qemu)
machine : CHRP IBM pSeries (emulated by qemu)
src/cpu/cpu.cpp +1 -1
@@ -489,7 +489,7 @@ void report_display_cpu_cstates(void) string *pkg_data = new string[pkg_tbl_size.cols * pkg_tbl_size.rows]; core_tbl_size.cols=2; - core_tbl_size.rows=(cstates_num *_package->children.size()) + core_tbl_size.rows=((cstates_num + 1) * _package->children.size()) + _package->children.size(); string *core_data = new string[core_tbl_size.cols * core_tbl_size.rows]; int num_cpus=0, num_cores=0;