Bug 376537 - ksysguardd crashed on kernel 4.9
Summary: ksysguardd crashed on kernel 4.9
Status: RESOLVED FIXED
Alias: None
Product: ksysguard
Classification: Applications
Component: ksysguardd (show other bugs)
Version: 5.9.2
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: KSysGuard Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-16 09:00 UTC by boestari.riko
Modified: 2017-02-19 04:18 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.8.6


Attachments
Proposed patch (510 bytes, patch)
2017-02-17 01:59 UTC, Christoph Feck
Details
ksysguard output (6.29 KB, text/plain)
2017-02-17 16:55 UTC, boestari.riko
Details
journal ctl output (1.24 KB, text/plain)
2017-02-17 16:57 UTC, boestari.riko
Details
screenshot (72.94 KB, image/png)
2017-02-17 17:01 UTC, boestari.riko
Details
valgrind ksysguard (19.29 KB, text/plain)
2017-02-18 02:30 UTC, boestari.riko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description boestari.riko 2017-02-16 09:00:35 UTC
https://bbs.archlinux.org/viewtopic.php?id=223041

so, on amd fx-6100, the /proc/stat reading is a bit mess. it affects ksysguard (and ksysguardd).

summary on /proc/stat reading:
cpu  2388 3 1916 41568 20533 0 39 0 0 0
cpu0 453 0 476 5343 4789 0 16 0 0 0
cpu3 325 0 304 7276 3115 0 4 0 0 0
cpu4 387 0 241 7540 2916 0 6 0 0 0
cpu5 411 1 360 6872 3446 0 4 0 0 0
cpu6 376 0 201 7305 3197 0 1 0 0 0
cpu7 433 0 331 7229 3066 0 4 0 0 0

it's jumping from cpu0 to cpu3. monitoring widgets & ksysguard failed bcos of this
Comment 1 boestari.riko 2017-02-16 14:16:41 UTC
i believe it also related to these bugs report:
https://bugs.kde.org/show_bug.cgi?id=374944
https://bugs.kde.org/show_bug.cgi?id=371942
Comment 2 Christoph Feck 2017-02-17 01:59:36 UTC
Created attachment 104068 [details]
Proposed patch

Indeed. It counts the number of "cpu<n>" lines, and only allocates that number of entries. But then, it uses the <n> number to index into the allocated array.

Could you test attached patch?
Comment 3 boestari.riko 2017-02-17 02:27:31 UTC
i'll try it tonight. currently at work now.
Comment 4 boestari.riko 2017-02-17 16:55:50 UTC
Created attachment 104075 [details]
ksysguard output
Comment 5 boestari.riko 2017-02-17 16:57:18 UTC
Created attachment 104076 [details]
journal ctl output

this is the journalctl output when running ksysguard
Comment 6 boestari.riko 2017-02-17 17:01:29 UTC
Created attachment 104077 [details]
screenshot

so, i built the latest ksysguard from github and include your changes.
running ksysguard, well, nothing changes, it's still running with errors. i include the screenshot. you can see at the bottom, ksysguard only shows number of processes, and missing average cpu usage, memory usage, etc. and in system load tab, the graph is not drawing at all. on previous comment, i also include output of ksysguard and journalctl. sorry for triple post, i have no idea how to attach multiple files here
Comment 7 boestari.riko 2017-02-17 17:11:26 UTC
and btw on my amd fx-6100, kernel 4.9.8 /sys/devices/system/cpu folder contains cpu0, cpu3-cpu7 just like in /proc/stat, and files /sys/devices/system/cpu/cpuX/cpufreq/stats/time_in_state is empty. hope this helps
Comment 8 Rog131 2017-02-17 18:31:26 UTC
(In reply to boestari.riko from comment #6)
> Created attachment 104077 [details]
> screenshot
> 
> so, i built the latest ksysguard from github and include your changes.
> running ksysguard, well, nothing changes, it's still running with errors. i
> include the screenshot. you can see at the bottom, ksysguard only shows
> number of processes, and missing average cpu usage, memory usage, etc. and
> in system load tab, the graph is not drawing at all. on previous comment, i
> also include output of ksysguard and journalctl. sorry for triple post, i
> have no idea how to attach multiple files here

Did you clean the $HOME/.local/share/ksysguard/ directory ?
Comment 9 Rog131 2017-02-17 18:44:38 UTC
At here: AMD FX-6100 (six core) & Arch Linux. With the Kernel 4.9.8 the core numbering is 0,3,4,5,6,7 -> The Ksysguard is crashing....


Downloading the Arch Ksysguard PKGBUILD: https://git.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/ksysguard

Applying the patch: patch -p1 -i /path/to/counter.diff

Wrapping the package: makepkg -e

Installing the package: pacman -U ksysguard-5.9.2-1-x86_64.pkg.tar.xz

Restarting the plasmashell: kquitapp5 plasmashell and then plasmashell

Testing the ksysguard -> The CPU History and the Network History are blank.

Cleaning (removing files from) the $HOME/.local/share/ksysguard/

Restarting the plasmashell and testing again - working - the core numbering is a bit strange 1,4,5,6,7,8 : http://imgur.com/ys2ADg9
Comment 10 Christoph Feck 2017-02-17 19:27:55 UTC
If it still crashes with the patch applied, please add a backtrace with full debug symbols, and ideally also a valgrind log (with debug symbols). Note that default packages in Arch do not have debug information, so you need to compile yourself, or test with a different distribution.
Comment 11 boestari.riko 2017-02-18 00:42:56 UTC
(In reply to Rog131 from comment #8)
> (In reply to boestari.riko from comment #6)
> > Created attachment 104077 [details]
> > screenshot
> > 
> > so, i built the latest ksysguard from github and include your changes.
> > running ksysguard, well, nothing changes, it's still running with errors. i
> > include the screenshot. you can see at the bottom, ksysguard only shows
> > number of processes, and missing average cpu usage, memory usage, etc. and
> > in system load tab, the graph is not drawing at all. on previous comment, i
> > also include output of ksysguard and journalctl. sorry for triple post, i
> > have no idea how to attach multiple files here
> 
> Did you clean the $HOME/.local/share/ksysguard/ directory ?

cleaning that directory gave the same result.
Comment 12 boestari.riko 2017-02-18 00:43:46 UTC
(In reply to Christoph Feck from comment #10)
> If it still crashes with the patch applied, please add a backtrace with full
> debug symbols, and ideally also a valgrind log (with debug symbols). Note
> that default packages in Arch do not have debug information, so you need to
> compile yourself, or test with a different distribution.

i know how to use valgrind, but how do i enable debug symbols? at compile time or at running time?
Comment 13 Christoph Feck 2017-02-18 02:15:05 UTC
At cmake time, with -DCMAKE_BUILD_TYPE=Debug
Comment 14 boestari.riko 2017-02-18 02:30:36 UTC
Created attachment 104087 [details]
valgrind ksysguard

here's the valgrind ksysguard output. i'm using flag --leak-check=full
Comment 15 Christoph Feck 2017-02-18 03:00:32 UTC
The valgrind memcheck log does not show any reason for a crash. The 'invalid reads' and 'invalid writes' seem to be gone, so I am wondering if it crashes at all.
Comment 16 boestari.riko 2017-02-18 03:13:32 UTC
(In reply to Christoph Feck from comment #15)
> The valgrind memcheck log does not show any reason for a crash. The 'invalid
> reads' and 'invalid writes' seem to be gone, so I am wondering if it crashes
> at all.

well, ksysguard itself is not crashing, but avrage cpu load, memory load, and graphs in system load not drawing at all. and on the process list, systemd-coredump keep surfacing continuously. after checking journalctl, it is related to ksysguardd like in attachment 104076 [details]
Comment 17 Christoph Feck 2017-02-18 03:32:43 UTC
Yes, but that backtrace has no debug symbols...
Comment 18 boestari.riko 2017-02-18 03:42:52 UTC
(In reply to Christoph Feck from comment #17)
> Yes, but that backtrace has no debug symbols...

i built it using following commands within build directory inside ksysguard project
[boes@ARCHHOME build]$cmake -DCMAKE_BUILD_TYPE=Debug ..
[boes@ARCHHOME build]$make
am i missing something here?
Comment 19 Christoph Feck 2017-02-18 04:17:25 UTC
I was referring to the attachment from comment #5. It clearly shows a crash, but the symbols are 'n/a' there.

Also, make sure ksysguard actually connects to your compiled version of ksysguardd, instead of the one from distribution packages.
Comment 20 boestari.riko 2017-02-18 04:40:32 UTC
(In reply to Christoph Feck from comment #19)
> I was referring to the attachment from comment #5. It clearly shows a crash,
> but the symbols are 'n/a' there.
> 
> Also, make sure ksysguard actually connects to your compiled version of
> ksysguardd, instead of the one from distribution packages.

how do i make sure compiled ksysguard connects to compiled ksysguardd? i have google this, but no manual or explanation on this topic.
Comment 21 Christoph Feck 2017-02-18 05:04:07 UTC
If everything else fails, install it to /usr and reboot.

cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr ..
make
sudo make install
Comment 22 boestari.riko 2017-02-18 05:22:52 UTC
(In reply to Christoph Feck from comment #21)
> If everything else fails, install it to /usr and reboot.
> 
> cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr ..
> make
> sudo make install

omg, yes this solve the problem. ksysguard behaves normally again, and no more error message on journalctl.
also, many monitoring widgets (thermal monitor, cpu load) is functional again, guess it depends on ksysguard.

but system load tab still not drawing cpu history & network history, only memory & swap history functioning. but this issue happened long before kernel 4.9. i guess i'll search google first.

thanks dude, now should i change the status to resolved?
Comment 23 Christoph Feck 2017-02-19 04:18:16 UTC
Git commit e4c58c2f6ef74bad065f7327c19c02a3dac88883 by Christoph Feck.
Committed on 19/02/2017 at 04:15.
Pushed by cfeck into branch 'Plasma/5.8'.

Fix array allocation for non-continuous cpu numbers
FIXED-IN: 5.8.6

Differential Revision: https://phabricator.kde.org/D4640

M  +2    -1    ksysguardd/Linux/stat.c

https://commits.kde.org/ksysguard/e4c58c2f6ef74bad065f7327c19c02a3dac88883