Bug 475506 - Screen locking failed because of too many open files, but rest of system works fine
Summary: Screen locking failed because of too many open files, but rest of system work...
Alias: None
Product: kscreenlocker
Classification: Plasma
Component: general (show other bugs)
Version: 5.27.4
Platform: openSUSE Linux
: NOR grave
Target Milestone: ---
Assignee: Plasma Bugs List
Depends on:
Reported: 2023-10-12 09:08 UTC by Thomas Murach
Modified: 2023-11-03 13:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Murach 2023-10-12 09:08:04 UTC
Due to a problem with an unrelated software component (KMozillaHelper, see https://www.opensuse-forum.de/thread/66654-maximum-number-of-clients-reached-kmozillahelper/ (German, unfortunately)) I recently had many processes running and files open even right after booting my system. This did not cause any noticeable problems. I could start my IDE for software development, browse the web, etc. As far as I can tell the only issue I had is that I could not lock my screen, either via keyboard shortcut or by clicking the lock icon in the task bar. The error message in the logs was this:
2023-10-09T13:14:55.692681+02:00 laptop ksmserver[4361]: QProcessPrivate::createPipe: Cannot create pipe 0x7fbf90004b78 (Too many open files)
2023-10-09T13:14:55.699846+02:00 laptop ksmserver[4361]: kscreenlocker: Greeter Process not available

Obviously this issue can be fixed by killing spurious kmozillahelper processes, but I do wonder why starting any other programm/process worked fine, and only the screen locker (a vital component!) could not be started. So please give this issue a thought before telling me to clean up my system ;-).

PS executing /usr/lib/kscreenlocker_greet manually did work as expected!

1. Open sufficiently many instances of KMozillaHelper
2. Try to lock the screen

Screen did not lock

Should have been locked

KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8

My "ulimit" settings:
$ ulimit -a
core file size               (blocks, -c) unlimited
data seg size              (kbytes, -d) unlimited
scheduling priority    (-e) 0
file size                        (blocks, -f) unlimited
pending signals          (-i) 127197
max locked memory (kbytes, -l) 64
max memory size      (kbytes, -m) unlimited
open files                    (-n) 1024
pipe size                      (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority       (-r) 0
stack size                    (kbytes, -s) 8192
cpu time                      (seconds, -t) unlimited
max user processes   (-u) 127197
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
Comment 1 Bug Janitor Service 2023-10-16 14:32:53 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/3413
Comment 2 Harald Sitter 2023-11-03 12:52:44 UTC
Git commit 5df2fe17c80eff6fdfcbd8385954e5b88a0f30c5 by Harald Sitter.
Committed on 03/11/2023 at 12:47.
Pushed by sitter into branch 'master'.

ksmserver: cap the amount of app restorations

when we restore more than ΒΌ of RLIMIT_NOFILE (default 1024) of a single
application it is incredibly likely that this application is being
defective (e.g. GUIless apps participating in session management but
also in autostarting -- resulting in ever multiplying instances).

when in excess, refuse to start **all** restorations of the application
(NOTE: this is why we loop everything twice)

M  +89   -15   ksmserver/server.cpp

Comment 3 Harald Sitter 2023-11-03 12:52:50 UTC
Git commit 318e8b123954792886a1133396d014d59930dc4d by Harald Sitter.
Committed on 03/11/2023 at 12:47.
Pushed by sitter into branch 'master'.

ksmserver: never allow ICE connections to exhaust RLIMIT_NOFILE

At most use `RLIMIT_NOFILE - 128`; the remainder is reserved for other
uses like invoking the lock screen, other sockets etc.

to implement this there's a trivial ref count on KSMConnection. When too
many references are active we'll force close connections again right
after creation

M  +21   -0    ksmserver/server.cpp