Bug 450830

Summary: drkonqi remains running after wayland session end, crashed applications eating CPU
Product: [Applications] drkonqi Reporter: pelzi
Component: generalAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: normal CC: sitter
Priority: NOR    
Version First Reported In: 5.23.5   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description pelzi 2022-02-25 13:50:20 UTC
SUMMARY

When ending a session, several background applications tend to crash for whatever reason, raising several instances of drkonqi. However, drkonqi doesn't seem to make any sense in this context, as the session is already closed, nothing can be shown to the user. drkonqi fails to handle this situation adequately and keeps running. All crashed applications remain infinitely busily looping (in wait4 calls on their respective drkonqi instance with WNOHANG flag set), eating a lot of CPU.

STEPS TO REPRODUCE
1. Use some of the less robust KDE components (kakonadi, korganizer, kmail often does the trick)
2. Log out from the desktop and wait for the display manager's login page
3. Check out in a text console if remainders of your session are still running, and analyse what they do

OBSERVED RESULT
All crashed applications remain infinitely busily looping (in wait4 calls on their respective drkonqi instance with WNOHANG flag set), eating a lot of CPU.

EXPECTED RESULT
Even in case of buggy applications, drkonqi correctly determines that the user session is already closed, does not attempt to show dialogues within those no longer existing sessions, but terminates cleanly instead.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Harald Sitter 2022-02-28 13:36:53 UTC
That makes no sense. There's literally code that checks if the session is closed https://invent.kde.org/plasma/drkonqi/-/blob/master/src/main.cpp#L78 so I am left inferring that the session wasn't closed when the crash occurred.

In any event https://www.freedesktop.org/software/systemd/man/logind.conf.html#KillUserProcesses= is your friend.