Skip to contentSkip to conversation

crash on powertop --debug --html=file.html

Powertop Jan-Simon Möller <dl9pf at gmx.de> 4 participants 12 messages Jun 26, 2012 – Jul 6, 2012

lore
Share & tools
lore

Jan-Simon Möller <dl9pf at gmx.de>

#0 lore raw

Hi all!

With git HEAD I see this crash:

$ ./src/powertop --debug --html=/home/dl9pf/powertop.1.html 
Loaded 0 prior measurements
Preparing to take measurements
Taking 1 measurement(s) for a duration of 20 second(s) each.
Segmentation fault (core dumped)
$ gdb ./src/powertop core
GNU gdb (GDB) SUSE (7.4.50.20120603-77.1)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/dl9pf/user/git/LF/powertop/src/powertop...done.
[New LWP 2714]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./src/powertop --debug --
html=/home/dl9pf/powertop.1.html'.
Program terminated with signal 11, Segmentation fault.
#0  0x000000000041f1dc in devlist_sort (i=0x875720, j=0x211) at 
devlist.cpp:273
273             if (i->pid != j->pid)
(gdb) bt full
#0  0x000000000041f1dc in devlist_sort (i=0x875720, j=0x211) at 
devlist.cpp:273
No locals.
#1  0x00000000004218b8 in 
std::__unguarded_linear_insert<__gnu_cxx::__normal_iterator<devuser**, 
std::vector<devuser*, std::allocator<devuser*> >  root(a)aragorn: 
/home/dl9pf/user/git/LF/powertop                                                                                           
[17:03] 
        __val = 0x875720
        __next = {_M_current = 0x889288}
#2  0x0000000000421071 in 
std::__unguarded_insertion_sort<__gnu_cxx::__normal_iterator<devuser**, 
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*, 
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 <devlist_sort(devuser*, 
devuser*)>)
    at /usr/include/c++/4.5/bits/stl_algo.h:2160
        __i = {_M_current = 0x889318}
#3  0x0000000000420358 in 
std::__final_insertion_sort<__gnu_cxx::__normal_iterator<devuser**, 
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*, 
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 <devlist_sort(devuser*, 
devuser*)>)
    at /usr/include/c++/4.5/bits/stl_algo.h:2193
No locals.
#4  0x000000000041f948 in std::sort<__gnu_cxx::__normal_iterator<devuser**, 
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*, 
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 <devlist_sort(devuser*, 
devuser*)>) at /usr/include/c++/4.5/bits/stl_algo.h:5252
No locals.
#5  0x000000000041f2e5 in report_show_open_devices () at devlist.cpp:306
        target = 0x68edc0 <two>
        i = 0
        prev = 
"\000_Y=\377\177\000\000\000\000\000\000\000\000\000\000\240_Y=\377\177\000\000@\332h\000\000\000\000\000\240\332h\000\000\000\000\000P\241\206", 
'\000' <repeats 29 times>, 
"\020\362h\000\000\000\000\000\360_Y=\377\177\000\000&\203@\000\000\000\000\000\360_Y=\377\177\000\000EKh\201x\230Y@\240\332h\000\000\000\000\000@\332h\000\000\000\000"
        proc = 
"\200\360h\000\000\000\000\000\001\000\000\000\000\000\000\000\350bU\001\000\000\000\000\340bU\001\000\000\000\000\020_Y=\377\177\000\000\020\320<\357\177\177\000\000\061\000\000\000\000\000\000\000\250\332h\000\000\000\000\000(a)_Y=\377\177\000\000\224\201@\000\000\000\000\000h_Y=\377\177\000\000\000\000\000\000\000\000\000\000  
0,0%\000kts/s\000\000\000\000\240_Y=\377\177\000\000T\016D\000\000\000\000"
#6  0x0000000000454a9b in one_measurement (seconds=20, workload=0x7fff3d5960a0 
"") at main.cpp:223
        tmp = 0
#7  0x0000000000454d81 in report (time=20, workload=0x7fff3d5960a0 "", 
iterations=1, file=0x7fff3d5970a0 "/home/dl9pf/powertop.1.html")
    at main.cpp:274
        i = 0
#8  0x0000000000455287 in main (argc=3, argv=0x7fff3d5981a8) at main.cpp:434
        option_index = 4
        c = -1
        wantreport = true
        iterations = 1

It runs with:

src/devlist.cpp +1 -1
index 93f2081..de98214 100644
@@ -303,7 +303,7 @@ void report_show_open_devices(void)
        if (target->size() == 0)
                return;
 
-       sort(target->begin(), target->end(), devlist_sort);
+//     sort(target->begin(), target->end(), devlist_sort);
 
        if (reporttype) {
                fprintf(reportout.http_report,"<h2>Process device 

activity</h2>\n <table width=\"100%%\">\n");

Looks like something is fishy in the sort for this case.

Best,
Jan-Simon

#1 lore raw
Quoted 4 lines · Jan-Simon Möller

Hi all!
With git HEAD I see this crash:

$ ./src/powertop --debug --html=/home/dl9pf/powertop.1.html

hum thanks for the trace, but can you give me more info on your system?

./src/powertop --debug --html=/home/dl9pf/powertop.1.html

Fedora 15, 16, and 17 seem not to have the problem

What kernel are you running? Can you send me your kernel config?

and are you modifying power to build on suse in any way?

here is my output.

$ sudo ./src/powertop --debug --html=/home/ceferron/powertop.1.html
Loaded 0 prior measurements
Preparing to take measurements
Taking 1 measurement(s) for a duration of 20 second(s) each.
PowerTOP outputing using base filename /home/ceferron/powertop.1.html
Quoted 108 lines

Loaded 0 prior measurements
Preparing to take measurements
Taking 1 measurement(s) for a duration of 20 second(s) each. Segmentation fault (core dumped)

$ gdb ./src/powertop core
GNU gdb (GDB) SUSE (7.4.50.20120603-77.1)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/dl9pf/user/git/LF/powertop/src/powertop...done.
[New LWP 2714]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./src/powertop --debug --
html=/home/dl9pf/powertop.1.html'.
Program terminated with signal 11, Segmentation fault.
#0  0x000000000041f1dc in devlist_sort (i=0x875720, j=0x211) at
devlist.cpp:273
273             if (i->pid != j->pid)
(gdb) bt full
#0  0x000000000041f1dc in devlist_sort (i=0x875720, j=0x211) at
devlist.cpp:273
No locals.
#1  0x00000000004218b8 in
std::__unguarded_linear_insert<__gnu_cxx::__normal_iterator<devuser**,
std::vector<devuser*, std::allocator<devuser*> >  root(a)aragorn:
/home/dl9pf/user/git/LF/powertop
[17:03]
         __val = 0x875720
         __next = {_M_current = 0x889288}
#2  0x0000000000421071 in
std::__unguarded_insertion_sort<__gnu_cxx::__normal_iterator<devuser**,
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*,
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 <devlist_sort(devuser*,
devuser*)>)
     at /usr/include/c++/4.5/bits/stl_algo.h:2160
         __i = {_M_current = 0x889318}
#3  0x0000000000420358 in
std::__final_insertion_sort<__gnu_cxx::__normal_iterator<devuser**,
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*,
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 <devlist_sort(devuser*,
devuser*)>)
     at /usr/include/c++/4.5/bits/stl_algo.h:2193
No locals.
#4  0x000000000041f948 in std::sort<__gnu_cxx::__normal_iterator<devuser**,
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*,
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 <devlist_sort(devuser*,
devuser*)>) at /usr/include/c++/4.5/bits/stl_algo.h:5252
No locals.
#5  0x000000000041f2e5 in report_show_open_devices () at devlist.cpp:306
         target = 0x68edc0 <two>
         i = 0
         prev =
"\000_Y=\377\177\000\000\000\000\000\000\000\000\000\000\240_Y=\377\177\000\000@\332h\000\000\000\000\000\240\332h\000\000\000\000\000P\241\206",
'\000' <repeats 29 times>,
"\020\362h\000\000\000\000\000\360_Y=\377\177\000\000&\203@\000\000\000\000\000\360_Y=\377\177\000\000EKh\201x\230Y@\240\332h\000\000\000\000\000@\332h\000\000\000\000"
         proc =
"\200\360h\000\000\000\000\000\001\000\000\000\000\000\000\000\350bU\001\000\000\000\000\340bU\001\000\000\000\000\020_Y=\377\177\000\000\020\320<\357\177\177\000\000\061\000\000\000\000\000\000\000\250\332h\000\000\000\000\000(a)_Y=\377\177\000\000\224\201@\000\000\000\000\000h_Y=\377\177\000\000\000\000\000\000\000\000\000\000
0,0%\000kts/s\000\000\000\000\240_Y=\377\177\000\000T\016D\000\000\000\000"
#6  0x0000000000454a9b in one_measurement (seconds=20, workload=0x7fff3d5960a0
"") at main.cpp:223
         tmp = 0
#7  0x0000000000454d81 in report (time=20, workload=0x7fff3d5960a0 "",
iterations=1, file=0x7fff3d5970a0 "/home/dl9pf/powertop.1.html")
     at main.cpp:274
         i = 0
#8  0x0000000000455287 in main (argc=3, argv=0x7fff3d5981a8) at main.cpp:434
         option_index = 4
         c = -1
         wantreport = true
         iterations = 1

It runs with:

src/devlist.cpp +1 -1
index 93f2081..de98214 100644
@@ -303,7 +303,7 @@ void report_show_open_devices(void)
         if (target->size() == 0)
                 return;
 
-       sort(target->begin(), target->end(), devlist_sort);
+//     sort(target->begin(), target->end(), devlist_sort);
 
         if (reporttype) {
                 fprintf(reportout.http_report,"<h2>Process device

activity</h2>\n <table width=\"100%%\">\n");

Looks like something is fishy in the sort for this case.

Best,
Jan-Simon
_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop

#2 lore raw
Quoted 11 lines · Chris Ferron
Quoted 4 lines · Jan-Simon Möller

Hi all!
With git HEAD I see this crash:

$ ./src/powertop --debug --html=/home/dl9pf/powertop.1.html

hum thanks for the trace, but can you give me more info on your system?

./src/powertop --debug --html=/home/dl9pf/powertop.1.html

Fedora 15, 16, and 17 seem not to have the problem

Also tested it on openSUSE 12.1 (Asparagus) (x86_64)"

Quoted 141 lines

What kernel are you running? Can you send me your kernel config?

and are you modifying power to build on suse in any way?

here is my output.

$ sudo ./src/powertop --debug --html=/home/ceferron/powertop.1.html
Loaded 0 prior measurements
Preparing to take measurements
Taking 1 measurement(s) for a duration of 20 second(s) each.
PowerTOP outputing using base filename /home/ceferron/powertop.1.html
Quoted 111 lines

Loaded 0 prior measurements
Preparing to take measurements
Taking 1 measurement(s) for a duration of 20 second(s) each. Segmentation fault (core dumped)

$ gdb ./src/powertop core
GNU gdb (GDB) SUSE (7.4.50.20120603-77.1)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show 
copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from 
/home/dl9pf/user/git/LF/powertop/src/powertop...done.
[New LWP 2714]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./src/powertop --debug --
html=/home/dl9pf/powertop.1.html'.
Program terminated with signal 11, Segmentation fault.
#0  0x000000000041f1dc in devlist_sort (i=0x875720, j=0x211) at
devlist.cpp:273
273             if (i->pid != j->pid)
(gdb) bt full
#0  0x000000000041f1dc in devlist_sort (i=0x875720, j=0x211) at
devlist.cpp:273
No locals.
#1  0x00000000004218b8 in
std::__unguarded_linear_insert<__gnu_cxx::__normal_iterator<devuser**,
std::vector<devuser*, std::allocator<devuser*> > root(a)aragorn:
/home/dl9pf/user/git/LF/powertop
[17:03]
         __val = 0x875720
         __next = {_M_current = 0x889288}
#2  0x0000000000421071 in
std::__unguarded_insertion_sort<__gnu_cxx::__normal_iterator<devuser**,
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*,
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 
<devlist_sort(devuser*,
devuser*)>)
     at /usr/include/c++/4.5/bits/stl_algo.h:2160
         __i = {_M_current = 0x889318}
#3  0x0000000000420358 in
std::__final_insertion_sort<__gnu_cxx::__normal_iterator<devuser**,
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*,
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 
<devlist_sort(devuser*,
devuser*)>)
     at /usr/include/c++/4.5/bits/stl_algo.h:2193
No locals.
#4  0x000000000041f948 in 
std::sort<__gnu_cxx::__normal_iterator<devuser**,
std::vector<devuser*, std::allocator<devuser*> > >, bool (*)(devuser*,
devuser*)> (__first=..., __last=..., __comp=0x41f1c2 
<devlist_sort(devuser*,
devuser*)>) at /usr/include/c++/4.5/bits/stl_algo.h:5252
No locals.
#5  0x000000000041f2e5 in report_show_open_devices () at devlist.cpp:306
         target = 0x68edc0 <two>
         i = 0
         prev =
"\000_Y=\377\177\000\000\000\000\000\000\000\000\000\000\240_Y=\377\177\000\000@\332h\000\000\000\000\000\240\332h\000\000\000\000\000P\241\206", 

'\000' <repeats 29 times>, "\020\362h\000\000\000\000\000\360_Y=\377\177\000\000&\203@\000\000\000\000\000\360_Y=\377\177\000\000EKh\201x\230Y@\240\332h\000\000\000\000\000@\332h\000\000\000\000"

proc =
"\200\360h\000\000\000\000\000\001\000\000\000\000\000\000\000\350bU\001\000\000\000\000\340bU\001\000\000\000\000\020_Y=\377\177\000\000\020\320<\357\177\177\000\000\061\000\000\000\000\000\000\000\250\332h\000\000\000\000\000(a)_Y=\377\177\000\000\224\201@\000\000\000\000\000h_Y=\377\177\000\000\000\000\000\000\000\000\000\000

0,0%\000kts/s\000\000\000\000\240_Y=\377\177\000\000T\016D\000\000\000\000"

#6 0x0000000000454a9b in one_measurement (seconds=20, workload=0x7fff3d5960a0
"") at main.cpp:223

         tmp = 0
#7  0x0000000000454d81 in report (time=20, workload=0x7fff3d5960a0 "",
iterations=1, file=0x7fff3d5970a0 "/home/dl9pf/powertop.1.html")
     at main.cpp:274
         i = 0

#8 0x0000000000455287 in main (argc=3, argv=0x7fff3d5981a8) at main.cpp:434
option_index = 4
c = -1
wantreport = true
iterations = 1

It runs with:

src/devlist.cpp +1 -0
index 93f2081..de98214 100644
@@ -303,7 +303,7 @@ void report_show_open_devices(void)
         if (target->size() == 0)
                 return;
  -       sort(target->begin(), target->end(), devlist_sort);
+//     sort(target->begin(), target->end(), devlist_sort);
           if (reporttype) {

fprintf(reportout.http_report,"<h2>Process device
activity</h2>\n <table width=\"100%%\">\n");

Quoted 8 lines

Looks like something is fishy in the sort for this case.

Best,
Jan-Simon
_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop

#3 lore raw
In reply to Jan-Simon Möller <dl9pf at gmx.de>
Quoted 1 line

(i=0x875720, j=0x211)

Hm, it seems pretty unlikely that std::allocator would allocate anything on such a low address. It rather expected i and j to be somewhere in

	-/+ N * sizeof(struct)

range.

So, there is something we don't known about your system, or we have memory corruption which I can't find at the moment.

	-ss
#4 lore raw

Am Mittwoch, 27. Juni 2012, 10:06:28 schrieb Sergey Senozhatsky:

Quoted 9 lines
Quoted 1 line

(i=0x875720, j=0x211)

Hm, it seems pretty unlikely that std::allocator would allocate anything on such a low address. It rather expected i and j to be somewhere in

	-/+ N * sizeof(struct)

range.

So, there is something we don't known about your system, or we have memory corruption which I can't find at the moment.

Nothing special, just opensuse 11.4 with all updates. It works fine on the same setup with an i586 kernel/userspace.

I'll look into that a bit more.

Best,
JS

#5 lore raw
Quoted 7 lines · Jan-Simon Möller
Quoted 7 lines
Quoted 1 line

(i=0x875720, j=0x211)

Hm, it seems pretty unlikely that std::allocator would allocate anything on such a low address. It rather expected i and j to be somewhere in

	-/+ N * sizeof(struct)

range.

Quoted 8 lines
Quoted 2 lines

So, there is something we don't known about your system, or we have memory corruption which I can't find at the moment.

Nothing special, just opensuse 11.4 with all updates. It works fine on the same setup with an i586 kernel/userspace.

I'll look into that a bit more.

Could you please run

valgrind --tool=memcheck --leak-check=full --show-reachable=yes --leak-resolution=high --track-origins=yes -v --log-file=./powertop-memcheck powertop --debug --html=file.html

and provide powertop-memcheck file?

	-ss
#6 lore raw

Am Mittwoch, 27. Juni 2012, 18:32:42 schrieb Sergey Senozhatsky:

Quoted 11 lines

Could you please run

valgrind --tool=memcheck --leak-check=full --show-reachable=yes
--leak-resolution=high --track-origins=yes -v --log-file=./powertop-memcheck powertop --debug --html=file.html

and provide powertop-memcheck file?

	-ss

Attached.

#7 lore raw
Quoted 8 lines · Jan-Simon Möller

Am Mittwoch, 27. Juni 2012, 18:32:42 schrieb Sergey Senozhatsky:

Quoted 7 lines

Could you please run

valgrind --tool=memcheck --leak-check=full --show-reachable=yes
--leak-resolution=high --track-origins=yes -v --log-file=./powertop-memcheck powertop --debug --html=file.html

Quoted 6 lines
Quoted 4 lines

and provide powertop-memcheck file?

	-ss

Attached.

Thanks, I'll take a look.

Meanwhile, could you please try the following patch?

---

 src/devlist.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
src/devlist.cpp +4 -3
index 93f2081..9f06b92 100644
@@ -146,11 +146,12 @@ void collect_open_devices(void)
 				if (!dev)
 					continue;
 				dev->pid = strtoull(entry->d_name, NULL, 10);
-				strncpy(dev->device, link, 251);
+				strncpy(dev->device, link, 250);
+				dev->device[251] = 0x00;
 				sprintf(filename, "/proc/%s/comm", entry->d_name);
-				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 31);
+				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 30);
+				dev->comm[31] = 0x00;
 				target->push_back(dev);
-
 			}
 		}
 		closedir(dir2);
#8 lore raw

no change.

Signature · 1 line
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com> schrieb:

Quoted 8 lines · Jan-Simon Möller

Am Mittwoch, 27. Juni 2012, 18:32:42 schrieb Sergey Senozhatsky:

Quoted 7 lines

Could you please run

valgrind --tool=memcheck --leak-check=full --show-reachable=yes --leak-resolution=high --track-origins=yes -v --log-file=./powertop-memcheck powertop --debug --html=file.html

Quoted 6 lines
Quoted 4 lines

and provide powertop-memcheck file?

	-ss

Attached.

Thanks, I'll take a look.

Meanwhile, could you please try the following patch?

---

src/devlist.cpp | 7 ++++---

1 file changed, 4 insertions(+), 3 deletions(-)
src/devlist.cpp +0 -0
index 93f2081..9f06b92 100644
@@ -146,11 +146,12 @@ void collect_open_devices(void)
				if (!dev)
					continue;
				dev->pid = strtoull(entry->d_name, NULL, 10);
-				strncpy(dev->device, link, 251);
+				strncpy(dev->device, link, 250);
+				dev->device[251] = 0x00;
				sprintf(filename, "/proc/%s/comm", entry->d_name);
-				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 31);
+				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 30);
+				dev->comm[31] = 0x00;
				target->push_back(dev);
-
			}
		}
		closedir(dir2);
#9 lore raw

Hi,

Could you please give it a try? (just a bunch of suspects). If it fails, it'd be nice to see valgrind output.

---

 src/devlist.cpp | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
src/devlist.cpp +11 -6
index 93f2081..e65981e 100644
@@ -89,7 +89,6 @@ void collect_open_devices(void)
 	}
 	target->resize(0);
 
-
 	dir = opendir("/proc/");
 	if (!dir)
 		return;
@@ -105,7 +104,7 @@ void collect_open_devices(void)
 		if (strcmp(entry->d_name, "self") == 0)
 			continue;
 
-		sprintf(filename, "/proc/%s/fd/", entry->d_name);
+		snprintf(filename, 4095, "/proc/%s/fd/", entry->d_name);
 
 		dir2 = opendir(filename);
 		if (!dir2)
@@ -113,12 +112,14 @@ void collect_open_devices(void)
 		while (1) {
 			int ret;
 			struct devuser * dev;
+			std::string comm;
+
 			entry2 = readdir(dir2);
 			if (!entry2)
 				break;
 			if (entry2->d_name[0] == '.')
 				continue;
-			sprintf(filename, "/proc/%s/fd/%s", entry->d_name, entry2->d_name);
+			snprintf(filename, 4095, "/proc/%s/fd/%s", entry->d_name, entry2->d_name);
 			memset(link, 0, 4096);
 			ret = readlink(filename, link, 4095);
 			if (ret < 0)
@@ -147,10 +148,14 @@ void collect_open_devices(void)
 					continue;
 				dev->pid = strtoull(entry->d_name, NULL, 10);
 				strncpy(dev->device, link, 251);
-				sprintf(filename, "/proc/%s/comm", entry->d_name);
-				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 31);
+				dev->device[251] = 0x00;
+				comm = read_sysfs_string("/proc/%s/comm", entry->d_name);
+				if (comm.empty())
+					dev->comm[0] = 0x00;
+				else
+					strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 31);
+				dev->comm[31] = 0x00;
 				target->push_back(dev);
-
 			}
 		}
 		closedir(dir2);
#10 lore raw
In reply to Jan-Simon Möller <dl9pf at gmx.de>
Quoted 8 lines · Jan-Simon Möller

Am Mittwoch, 27. Juni 2012, 10:06:28 schrieb Sergey Senozhatsky:

Quoted 7 lines
Quoted 1 line

(i=0x875720, j=0x211)

Hm, it seems pretty unlikely that std::allocator would allocate anything on such a low address. It rather expected i and j to be somewhere in

	-/+ N * sizeof(struct)

range.

Quoted 6 lines
Quoted 2 lines

So, there is something we don't known about your system, or we have memory corruption which I can't find at the moment.

Nothing special, just opensuse 11.4 with all updates. It works fine on the same setup with an i586 kernel/userspace.

Ok, speaking on the kernel, I see that you run 3.5-rc2, have you tried 3.5.0-rc4-01004-gcee4d98?

	-ss
#11 lore raw
In reply to Sergey Senozhatsky
Quoted 9 lines · Sergey Senozhatsky
Quoted 1 line

(i=0x875720, j=0x211)

Hm, it seems pretty unlikely that std::allocator would allocate anything on such a low address. It rather expected i and j to be somewhere in

	-/+ N * sizeof(struct)

range.

So, there is something we don't known about your system, or we have memory corruption which I can't find at the moment.

maybe Jan Simon can run powertop in valgrind to check ?

Quoted 8 lines

	-ss

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop