Bug 373274

Summary: ksmserver eats memory and does not lock screen
Product: [Unmaintained] ksmserver Reporter: johann.jacobsohn
Component: generalAssignee: Lubos Lunak <l.lunak>
Status: RESOLVED FIXED    
Severity: normal CC: fincer89, fuznacious, gianogli, kde, kde, kde_bugs, kde_org, ludo444, mister.freeman, patrick.rudolph, sancelot, simonandric5
Priority: NOR    
Version: 5.8.4   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description johann.jacobsohn 2016-12-05 07:25:15 UTC
On Fedora 25 and from plasma-workspace 5.8.4 on, ksmserver uses more and more memory. Eventually (several days), it has consumed so much memory that the systems grinds to a halt (until it is killed by oomkiller). Long before then, screen locking stops working (that is, the computer is not locked after waking from standby, which makes me extremely nervous). Reboot fixes the issue for a while.


For example, after 17:36 hours of activity, ksmserver uses 2,5Gb of memory. Screen locking does not work anymore.

ps -eo rss,pid,user,command --sort -rss | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | head -n2
         0.00 Mb COMMAND 
      2616.69 Mb /usr/bin/ksmserver

journalctl --since "today" | grep ksmserver     
Dez 05 06:36:23 jjacobsohn ksmserver[16366]: QXcbWindow: Unhandled client message: "_NET_CURRENT_DESKTOP"
Dez 05 06:49:59 jjacobsohn ksmserver[16366]: QXcbWindow: Unhandled client message: "_NET_CURRENT_DESKTOP"
Dez 05 06:52:23 jjacobsohn ksmserver[16366]: QXcbWindow: Unhandled client message: "_NET_CURRENT_DESKTOP"
Dez 05 06:54:17 jjacobsohn ksmserver[16366]: QXcbWindow: Unhandled client message: "_NET_CURRENT_DESKTOP"
Dez 05 07:00:38 jjacobsohn ksmserver[16366]: Greeter Process not available
Dez 05 07:00:43 jjacobsohn systemd-logind[15701]: Delay lock is active (UID 1000/jjacobsohn, PID 16366/ksmserver) but inhibitor timeout is reached.
Dez 05 07:54:07 jjacobsohn ksmserver[16366]: Greeter Process not available
Dez 05 07:54:12 jjacobsohn systemd-logind[15701]: Delay lock is active (UID 1000/jjacobsohn, PID 16366/ksmserver) but inhibitor timeout is reached.

Is there anything I could do to help fix the issue? If it helps, I could try to compile and bisect ksmserver.
Comment 1 johann.jacobsohn 2017-02-09 13:29:33 UTC
This problem persists in 5.8.5
Comment 2 Potomac 2017-03-12 19:30:13 UTC
I can confirm this bug,

randomly after several hours ksmserver eats too much ram, for example on systems with 4 Gb ram ksmserver can eat 3 Gb, which can cause swap disk operatin, and slowdown the PC,

I use archlinux 64 bits, plasma 5.9.3-1
Comment 3 gianogli 2017-03-21 08:05:05 UTC
I can confirm this bug.
After 15 days, in my workstation, the ksmserver process is using 20GB of RAM.
Is there a way to debug this leak?
Thanks...

I'm using Debian Testing with plasma-workspace 4:5.8.4-1 (amd64).
Comment 4 Craig Conner 2017-03-31 23:36:10 UTC
Confirmed, ksmserver on my desktop is using about 6.9 GB RAM right now...  I've only been logged in for about two hours.

I also happen to use Fedora, and this persists in package plasma-workspace-5.8.6

# rpm -q --whatprovides /usr/bin/ksmserver
plasma-workspace-5.8.6-6.fc25.x86_64


KiB Mem : 16400052 total,  3828064 free,  9202236 used,  3369752 buff/cache
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                      
 7943 fuzzy     39  19  9.875g 6.756g  23496 S   0.0 43.2   4:26.76 ksmserver


...or, as another person expressed it,

# ps -eo rss,pid,user,command --sort -rss | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | head -n2
         0.00 Mb COMMAND 
      6918.64 Mb /usr/bin/ksmserver


My system:
Intel(R) Core(TM) i5-3550 CPU @ 3.30GHz,16 GB RAM, and in case it's relevant,
nvidia GTX 1060 (6GB) (and nvidia's drivers, version 375.39)
Comment 5 Matthias 2017-04-15 15:38:20 UTC
*** This bug has been confirmed by popular vote. ***
Comment 6 Christoph Feck 2017-04-21 19:45:06 UTC
*** Bug 378551 has been marked as a duplicate of this bug. ***
Comment 7 Patrick Rudolph 2017-06-26 08:42:40 UTC
I've noticed this issue on several of out test system. We are using  plasma-workspace 5.8.6 on Intel Skylake based platforms.

Usually the memory grows a few hundreds of byte per minute.
Sometimes it grows much faster.
No special processes are running, just plain KDE desktop.

The issue wasn't observed on other (older) Intel platforms.
The issue wasn't observed in case the desktop is started on a VNC session.

I noticed that stopping the plasmashell process (using SIGSTOP) stops the ksmserver memory from growing. I suspect it's some kind of bug in the plasmashell that only exists on some display drivers.

As the display driver might be related adding some debug infos:
* Mesa
* Vendor: Intel Open Source Technology Center (0x8086)
* Device: Mesa DRI Intel(R) HD Graphics 530 (Skylake GT2)  (0x1912)
* Version: 17.0.4
* modeset driver
Comment 8 Patrick Rudolph 2017-06-27 14:29:13 UTC
I could reproduce the issue:
Moving the mouse over plasmashell's tray icons or startmenu entries causes the memory in ksmserver to rise.

By looking at plasmashell's output I found thousands of "_xgeWireToEvent: Unknown extension 148, this should never happen.".

By redirecting plasmashell's output to /dev/null the issue no longer occurs.

It looks like ksmserver doesn't read/discard the spawned child's output, but collects them in some internal buffer.

The hotfix for me is to install libXext 1.3.3. But it just covers the bug, as other applications could spam a lot and cause a memory bloat in ksmserver.
Comment 9 David Edmundson 2017-09-04 17:10:55 UTC
Output handling was changing in 5.8.7 onwards.

Please reopen if you still have this issue.
Comment 10 Stéphane ANCELOT 2017-09-05 06:38:48 UTC
Hi,
I can confirm this bug, too on intel J1900 platform / and plasma 5.8.6(opensuse 42.2).
after two days , the ksmserver uses 57% of ram.
Nobody uses the system.

The only thing I found in journalctl is oomkiller messages :

pt. 05 02:03:22 linux-qhf9 kernel: Killed process 1418 (plasmashell) total-vm:3196376kB, anon-rss:74220kB, file-rss:15936kB
sept. 05 02:03:22 linux-qhf9 kernel: Purging GPU memory, 0 bytes freed, 5283840 bytes still pinned.
sept. 05 02:03:22 linux-qhf9 kernel: Qt bearer threa invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
sept. 05 02:03:22 linux-qhf9 kernel: Qt bearer threa cpuset=/ mems_allowed=0
sept. 05 02:03:22 linux-qhf9 kernel: CPU: 2 PID: 1464 Comm: Qt bearer threa Not tainted 3.18.20cobalt #1
sept. 05 02:03:22 linux-qhf9 kernel: Hardware name: To be filled by O.E.M. To be filled by O.E.M./Aptio CRB, BIOS 5.6.5 02/04/2015
sept. 05 02:03:22 linux-qhf9 kernel:  0000000000000000 ffff880037504648 ffffffff814252d9 ffff880037504000
sept. 05 02:03:22 linux-qhf9 kernel:  ffffffff81422c4d 0000000000000401 0000000000000000 0000000000000000
sept. 05 02:03:22 linux-qhf9 kernel:  ffff8800a186faf8 0000000000000000 ffffffffa02326b3 0000000000000000
sept. 05 02:03:22 linux-qhf9 kernel: Call Trace:
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff814252d9>] ? dump_stack+0x49/0x6a
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff81422c4d>] ? dump_header.isra.8+0x73/0x1e0
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffffa02326b3>] ? i915_gem_shrinker_oom+0x179/0x1aa [i915]
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff81428ee5>] ? _raw_spin_unlock_irqrestore+0xc/0x1f
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810c3550>] ? oom_kill_process+0x70/0x322
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff8103d6e9>] ? has_ns_capability_noaudit+0x32/0x3d
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810c3d97>] ? out_of_memory+0x438/0x451
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810c75bd>] ? __alloc_pages_nodemask+0x5fa/0x641
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff81244db1>] ? radix_tree_lookup_slot+0x10/0x23
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810ed195>] ? alloc_pages_current+0xaf/0xcc
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810c2a2f>] ? filemap_fault+0x218/0x36c
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810d9b84>] ? __do_fault+0x33/0x82
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810dae9b>] ? do_read_fault.isra.84+0x18e/0x21a
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff8142a440>] ? apic_timer_interrupt+0x60/0x90
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810dc44d>] ? handle_mm_fault+0x14e/0x8e6
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff8102dabf>] ? __do_page_fault+0x26a/0x34a
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff8106a14c>] ? rcu_irq_exit+0xf/0x5f
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810248c1>] ? __ipipe_do_IRQ+0x6f/0x7a
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff81097fe3>] ? __ipipe_get_current_domain+0x5/0xd
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff81097fe3>] ? __ipipe_get_current_domain+0x5/0xd
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff810248c7>] ? __ipipe_do_IRQ+0x75/0x7a
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff8102dbf1>] ? do_page_fault+0x37/0x5a
sept. 05 02:03:22 linux-qhf9 kernel:  [<ffffffff8142b1d2>] ? page_fault+0x22/0x60
sept. 05 02:03:22 linux-qhf9 kernel: Mem-Info:
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 DMA per-cpu:
sept. 05 02:03:22 linux-qhf9 kernel: CPU    0: hi:    0, btch:   1 usd:   0
sept. 05 02:03:22 linux-qhf9 kernel: CPU    1: hi:    0, btch:   1 usd:   0
sept. 05 02:03:22 linux-qhf9 kernel: CPU    2: hi:    0, btch:   1 usd:   0
sept. 05 02:03:22 linux-qhf9 kernel: CPU    3: hi:    0, btch:   1 usd:   0
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 DMA32 per-cpu:
sept. 05 02:03:22 linux-qhf9 kernel: CPU    0: hi:  186, btch:  31 usd:  58
sept. 05 02:03:22 linux-qhf9 kernel: CPU    1: hi:  186, btch:  31 usd: 169
sept. 05 02:03:22 linux-qhf9 kernel: CPU    2: hi:  186, btch:  31 usd:  28
sept. 05 02:03:22 linux-qhf9 kernel: CPU    3: hi:  186, btch:  31 usd:  49
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 Normal per-cpu:
sept. 05 02:03:22 linux-qhf9 kernel: CPU    0: hi:  186, btch:  31 usd:  29
sept. 05 02:03:22 linux-qhf9 kernel: CPU    1: hi:  186, btch:  31 usd:  69
sept. 05 02:03:22 linux-qhf9 kernel: CPU    2: hi:  186, btch:  31 usd:  30
sept. 05 02:03:22 linux-qhf9 kernel: CPU    3: hi:  186, btch:  31 usd:  59
sept. 05 02:03:22 linux-qhf9 kernel: active_anon:771616 inactive_anon:54480 isolated_anon:0
                                      active_file:96 inactive_file:85 isolated_file:0
                                      unevictable:127551 dirty:0 writeback:0 unstable:0
                                      free:6727 slab_reclaimable:3261 slab_unreclaimable:7521
                                      mapped:34939 shmem:58310 pagetables:7377 bounce:0
                                      free_cma:0
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 DMA free:15352kB min:28kB low:32kB high:40kB active_anon:216kB inactive_anon:116kB active_file:4kB inactive_file:4kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15920kB managed:15836kB mlocked:0kB dirty:0kB wr
sept. 05 02:03:22 linux-qhf9 kernel: lowmem_reserve[]: 0 2874 3832 3832
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 DMA32 free:9664kB min:5928kB low:7408kB high:8892kB active_anon:2312232kB inactive_anon:165388kB active_file:244kB inactive_file:388kB unevictable:391440kB isolated(anon):0kB isolated(file):0kB present:3020080kB managed:2946292
sept. 05 02:03:22 linux-qhf9 kernel: lowmem_reserve[]: 0 0 958 958
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 Normal free:1892kB min:1976kB low:2468kB high:2964kB active_anon:774016kB inactive_anon:52416kB active_file:136kB inactive_file:0kB unevictable:118764kB isolated(anon):0kB isolated(file):0kB present:1048576kB managed:981700kB m
sept. 05 02:03:22 linux-qhf9 kernel: lowmem_reserve[]: 0 0 0 0
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 DMA: 2*4kB (UM) 3*8kB (UE) 4*16kB (UM) 1*32kB (E) 2*64kB (UE) 2*128kB (EM) 2*256kB (UE) 2*512kB (EM) 3*1024kB (UEM) 3*2048kB (EMR) 1*4096kB (M) = 15360kB
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 DMA32: 1444*4kB (UE) 0*8kB 2*16kB (R) 0*32kB 0*64kB 1*128kB (R) 0*256kB 1*512kB (R) 1*1024kB (R) 1*2048kB (R) 0*4096kB = 9520kB
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 Normal: 404*4kB (UER) 6*8kB (R) 2*16kB (R) 2*32kB (R) 1*64kB (R) 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 1824kB
sept. 05 02:03:22 linux-qhf9 kernel: Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
sept. 05 02:03:22 linux-qhf9 kernel: 84045 total pagecache pages
sept. 05 02:03:22 linux-qhf9 kernel: 1021144 pages RAM
...skipping...
sept. 05 02:03:22 linux-qhf9 kernel: [ 1388]  1000  1388   843624   687423    1526        0             0 ksmserver
sept. 05 02:03:22 linux-qhf9 kernel: [ 1393]  1000  1393   132393     2323     170        0             0 kaccess
sept. 05 02:03:22 linux-qhf9 kernel: [ 1396]     0  1396    56628     2001      41        0             0 upowerd
sept. 05 02:03:22 linux-qhf9 kernel: [ 1412]  1000  1412   129704     3168     166        0             0 kglobalaccel5
sept. 05 02:03:22 linux-qhf9 kernel: [ 1413]  1000  1413   751667     6461     234        0             0 kwin_x11
sept. 05 02:03:22 linux-qhf9 kernel: [ 1416]  1000  1416   163288     3289     198        0             0 kdeconnectd
sept. 05 02:03:22 linux-qhf9 kernel: [ 1417]  1000  1417   197681     8377     256        0             0 krunner
sept. 05 02:03:22 linux-qhf9 kernel: [ 1421]  1000  1421   170058     3506     179        0             0 polkit-kde-auth
sept. 05 02:03:22 linux-qhf9 kernel: [ 1423]  1000  1423    68189     1415      35        0             0 gvfsd
sept. 05 02:03:22 linux-qhf9 kernel: [ 1424]  1000  1424   129505     2640     166        0             0 xembedsniproxy
sept. 05 02:03:22 linux-qhf9 kernel: [ 1432]  1000  1432   106003     1677      41        0             0 gvfsd-fuse
sept. 05 02:03:22 linux-qhf9 kernel: [ 1450]  1000  1450    44582     1114      23        0             0 dconf-service
sept. 05 02:03:22 linux-qhf9 kernel: [ 1468]  1000  1468     3281      510      11        0             0 interface_machi
sept. 05 02:03:22 linux-qhf9 kernel: [ 1470]  1000  1470    17643     4216      39        0             0 x11vnc
sept. 05 02:03:22 linux-qhf9 kernel: [ 1472]  1000  1472   167879     3460     178        0             0 org_kde_powerde
sept. 05 02:03:22 linux-qhf9 kernel: [ 1491]  1000  1491   112158     4667     141        0             0 smb4k
sept. 05 02:03:22 linux-qhf9 kernel: [ 1494]  1000  1494   208401     2748     185        0             0 kactivitymanage
sept. 05 02:03:22 linux-qhf9 kernel: [ 1515]  1000  1515   129611     3104     167        0             0 kactivitymanage
sept. 05 02:03:22 linux-qhf9 kernel: [ 1586]     0  1586    10668     6063      26        0             0 creven
sept. 05 02:03:22 linux-qhf9 kernel: [ 1595]  1000  1595    85623     1540      90        0             0 kscreen_backend
sept. 05 02:03:22 linux-qhf9 kernel: [ 1609]     0  1609     3054      288      11        0             0 numalliance_CN6
sept. 05 02:03:22 linux-qhf9 kernel: [ 1610]     0  1610     3054      224      11        0             0 numalliance_CN6
sept. 05 02:03:22 linux-qhf9 kernel: [ 1612]     0  1612    10598     5993      26        0             0 onsigterm
sept. 05 02:03:22 linux-qhf9 kernel: [ 1613]     0  1613    10604     5982      26        0             0 compiler
sept. 05 02:03:22 linux-qhf9 kernel: [ 1614]     0  1614     1052      184       8        0             0 tee
sept. 05 02:03:22 linux-qhf9 kernel: [ 1633]     0  1633    33613     9668      40        0             0 automat
sept. 05 02:03:22 linux-qhf9 kernel: [ 1634]     0  1634     1052      180       8        0             0 tee
sept. 05 02:03:22 linux-qhf9 kernel: [ 1641]  1000  1641   129603     3107     166        0             0 kuiserver5
sept. 05 02:03:22 linux-qhf9 kernel: [ 1693]  1000  1693     3281      240      11        0             0 interface_machi
sept. 05 02:03:22 linux-qhf9 kernel: [ 1695]  1000  1695     3281      333      11        0             0 interface_machi
sept. 05 02:03:22 linux-qhf9 kernel: [ 1697]  1000  1697     3281      333      11        0             0 interface_machi
sept. 05 02:03:22 linux-qhf9 kernel: [ 1699]  1000  1699   118615    18692     195        0             0 python
sept. 05 02:03:22 linux-qhf9 kernel: [ 1700]  1000  1700     3281       78      10        0             0 interface_machi
sept. 05 02:03:22 linux-qhf9 kernel: [ 1704]  1000  1704    10614     6009      26        0             0 traite_defauts
sept. 05 02:03:22 linux-qhf9 kernel: [ 1705]  1000  1705     1441      317       7        0             0 tee
sept. 05 02:03:22 linux-qhf9 kernel: [ 1709]  1000  1709   300091   100336     405        0             0 python
sept. 05 02:03:22 linux-qhf9 kernel: [ 1747]  1000  1747    47769    10929      69        0             0 python
sept. 05 02:03:22 linux-qhf9 kernel: [ 1750]  1000  1750   135725    12768     165        0             0 onboard
sept. 05 02:03:22 linux-qhf9 kernel: [ 1758]  1000  1758    88854     1893      42        0             0 at-spi-bus-laun
sept. 05 02:03:22 linux-qhf9 kernel: [ 1763]  1000  1763     9903      912      24        0             0 dbus-daemon
sept. 05 02:03:22 linux-qhf9 kernel: [ 1765]  1000  1765    48677     1205      32        0             0 at-spi2-registr
sept. 05 02:03:22 linux-qhf9 kernel: [29707]  1000 29707   139327     9349     167        0             0 emacs-gtk
sept. 05 02:03:22 linux-qhf9 kernel: [29719]  1000 29719    10366      942      24        0             0 gconfd-2
sept. 05 02:03:22 linux-qhf9 kernel: [ 1733]     0  1733    28995      458      23        0             0 lvmetad
sept. 05 02:03:22 linux-qhf9 kernel: [ 5862]     0  5862    52324     1214      39        0             0 nm-dispatcher
sept. 05 02:03:22 linux-qhf9 kernel: [ 5871]     0  5871     2945       73      11        0             0 nfs
sept. 05 02:03:22 linux-qhf9 kernel: [ 5872]     0  5872     6295      328      16        0             0 systemctl
sept. 05 02:03:22 linux-qhf9 kernel: Out of memory: Kill process 1388 (ksmserver) score 698 or sacrifice child
sept. 05 02:03:22 linux-qhf9 kernel: Killed process 1417 (krunner) total-vm:790724kB, anon-rss:17548kB, file-rss:15960kB

I will try migrating oepnsuse 42.3 plasma 5.8.7