Skip to contentSkip to conversation

Bug-fix:Segmentation fault with powertop --html

PATCH In review Alexandra Yates 2 participants 5 messages May 21, 2014 – May 22, 2014

lore
Share & tools
lore

Alexandra Yates

author
#0 lore raw

PATCH 1/1 Bug-fix:Segmentation fault with powertop --html

This patch fixes the segmentation fault erros seen in powertop --html.

Reported by: Julian Wollrath" <jwollrath(a)web.de>

Julian can you test the patch please. thank you. AY.

Alexandra Yates (1):
Bug-fix: html & csv report core indexes

 src/cpu/cpu.cpp |   30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/1 Bug-fix: html & csv report core indexes

This patch allows the supported no Intel CPUs to be included on html & CSV reports. It fixes the rows index needed for package data. Additionally, fixes the calculation of title indexes when cores are absent from the CPU. These changes are related to C-states and P-states reports

Signed-off-by Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
 src/cpu/cpu.cpp |   30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)
src/cpu/cpu.cpp +21 -9
index 0a7c487..72d5726 100644
@@ -466,7 +466,7 @@ void report_display_cpu_cstates(void)
 			continue;
 		/* Tables for PKG, CORE, CPU */
 		pkg_tbl_size.cols=2;
-		pkg_tbl_size.rows= cstates_num+1;
+		pkg_tbl_size.rows= ((cstates_num+1)-LEVEL_HEADER)+1;
 		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
@@ -608,12 +608,18 @@ void report_display_cpu_cstates(void)
 		}
 
 		/* Report Output */
-		title=title/core_num;
+		if(core_num > 0)
+			title=title/core_num;
+		else if( _core->children.size() > 0)
+			title=title/_core->children.size();
+
 		init_pkg_table_attr(&std_table_css, pkg_tbl_size.rows,  pkg_tbl_size.cols);
 		report.add_table(pkg_data, &std_table_css);
-		init_core_table_attr(&std_table_css, title+1, core_tbl_size.rows,
+		if (!_core->can_collapse()){
+			init_core_table_attr(&std_table_css, title+1, core_tbl_size.rows,
 				core_tbl_size.cols);
-		report.add_table(core_data, &std_table_css);
+			report.add_table(core_data, &std_table_css);
+		}
 		init_cpu_table_attr(&std_table_css, title+1, cpu_tbl_size.rows,
 				cpu_tbl_size.cols);
 		report.add_table(cpu_data, &std_table_css);
@@ -625,7 +631,7 @@ void report_display_cpu_pstates(void)
 {
 	char buffer[512], buffer2[512], tmp_num[50];
 	unsigned int package, core, cpu;
-	int line;
+	int line, title=0;
 	class abstract_cpu *_package, * _core, * _cpu;
 	unsigned int i, pstates_num;
 	const char* core_type = NULL;
@@ -671,7 +677,7 @@ void report_display_cpu_pstates(void)
 
 		/*  Tables for PKG, CORE, CPU */
 		pkg_tbl_size.cols=2;
-		pkg_tbl_size.rows=pstates_num+2;
+		pkg_tbl_size.rows=((pstates_num+1)-LEVEL_HEADER)+2;
 		string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
@@ -790,10 +796,16 @@ void report_display_cpu_pstates(void)
 		}
 		init_pkg_table_attr(&std_table_css, pkg_tbl_size.rows, pkg_tbl_size.cols);
 		report.add_table(pkg_data, &std_table_css);
-		init_core_table_attr(&std_table_css, (pstates_num+2),
+		if(!_core->can_collapse()){
+			title=pstates_num+2;
+			init_core_table_attr(&std_table_css, title,
 				core_tbl_size.rows, core_tbl_size.cols);
-		report.add_table(core_data, &std_table_css);
-		init_cpu_table_attr(&std_table_css, (pstates_num+2),
+			report.add_table(core_data, &std_table_css);
+		} else {
+			title=pstates_num+1;
+		}
+
+		init_cpu_table_attr(&std_table_css, title,
 				cpu_tbl_size.rows, cpu_tbl_size.cols);
 		report.add_table(cpu_data, &std_table_css);
 	}
Signature · 1 line
1.7.9.5
author
#2 lore raw
In reply to Alexandra Yates
Quoted 7 lines

This patch fixes the segmentation fault erros seen in powertop --html.

Reported by: Julian Wollrath" <jwollrath(a)web.de>

Julian can you test the patch please. thank you. AY.

Quoted 10 lines

Alexandra Yates (1):
Bug-fix: html & csv report core indexes

 src/cpu/cpu.cpp |   30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

--
1.7.9.5

The patch name is: [PATCH] Bug-fix: html & csv report core indexes.

Thank you,
Alexandra.

#3 lore raw
In reply to Alexandra Yates
Quoted 1 line

Julian can you test the patch please. thank you. AY.

Thank you for the patch but unfortunately powertop still segfaults:

$ powertop --html
Loaded 750 prior measurements
RAPL device for cpu 0
RAPL device for cpu 0
Preparing to take measurements
  unknown op '{'
*** Error in `powertop': free(): invalid pointer: 0x000000000187cdef ***
Taking 1 measurement(s) for a duration of 20 second(s) each.
[1]    22616 segmentation fault (core dumped)  powertop --html
Backtrace:
#0  0x00007f63d8c8e1af in std::string::assign(std::string const&) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x0000000000410f31 in operator= (__str="C1", this=0x7fff65b509a0)
    at /usr/include/c++/4.8/bits/basic_string.h:547

#2 report_display_cpu_cstates () at cpu/cpu.cpp:587
#3 0x00000000004493f4 in one_measurement (seconds=seconds(a)entry=20, workload=workload(a)entry=0x7fff65b521b0 "") at main.cpp:221 #4 0x00000000004496a6 in make_report (time=20, workload=workload(a)entry=0x7fff65b521b0 "", iterations=iterations(a)entry=1, file=file(a)entry=0x7fff65b511b0 "powertop.html") at main.cpp:264 #5 0x000000000040741d in main (argc=2, argv=0x7fff65b532d8) at main.cpp:441

Cheers,
Julian

author
#4 lore raw
Quoted 28 lines
Quoted 2 lines

Julian can you test the patch please. thank you. AY.

Thank you for the patch but unfortunately powertop still segfaults:

$ powertop --html
Loaded 750 prior measurements
RAPL device for cpu 0
RAPL device for cpu 0
Preparing to take measurements
  unknown op '{'
*** Error in `powertop': free(): invalid pointer: 0x000000000187cdef ***
Taking 1 measurement(s) for a duration of 20 second(s) each.
[1]    22616 segmentation fault (core dumped)  powertop --html
Backtrace:
#0  0x00007f63d8c8e1af in std::string::assign(std::string const&) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x0000000000410f31 in operator= (__str="C1", this=0x7fff65b509a0)
    at /usr/include/c++/4.8/bits/basic_string.h:547

#2 report_display_cpu_cstates () at cpu/cpu.cpp:587
#3 0x00000000004493f4 in one_measurement (seconds=seconds(a)entry=20, workload=workload(a)entry=0x7fff65b521b0 "") at main.cpp:221 #4 0x00000000004496a6 in make_report (time=20, workload=workload(a)entry=0x7fff65b521b0 "", iterations=iterations(a)entry=1, file=file(a)entry=0x7fff65b511b0 "powertop.html") at main.cpp:264 #5 0x000000000040741d in main (argc=2, argv=0x7fff65b532d8) at main.cpp:441

Quoted 3 lines

Cheers,
Julian

Julian, thank you for testing. The patches I sent you yesterday fixed the previous segfault. I'm currently looking into another solution.

Thank you,
Alexandra.