D8673: Sanitize signal handling in ksmserver

Jiří Paleček noreply at phabricator.kde.org
Mon Nov 6 00:22:09 UTC 2017


jpalecek created this revision.
Restricted Application added a project: Plasma.
Restricted Application added a subscriber: plasma-devel.

REVISION SUMMARY
  The TERM signal handling in ksmserver invokes functions which
  are not async-signal safe, like Qt functions and C++
  destructors. Moreover, the signal handling can occur in other than the
  main thread, which leads to Qt complaining about functions being
  invoked from the wrong thread. Such a crash can be seen in a report of
  "https://bugs.kde.org/show_bug.cgi?id=384316" <https://phabricator.kde.org/w/bug_384316/>.
  
  To fix both of these issues, this change makes the signal handling use
  the self-pipe trick, which signals the need for termination to the
  main thread by writing to a special-purpose file descriptor. The main
  loop then takes care of the termination. This is mostly inspired by http://doc.qt.io/qt-5/unix-signals.html.
  
  Note that `QApplication::quit` already does what we need when destroying
  the server, particularly deleting `the_server`/calling `cleanUp()`.
  
  BTW I noticed the code (here and in XIO error handler) makes quite
  sure the_server is zeroed. However, other code in ksmserver is not so
  keen on checking `the_server` is !0 when using it.

REPOSITORY
  R120 Plasma Workspace

BRANCH
  Plasma/5.10

REVISION DETAIL
  https://phabricator.kde.org/D8673

AFFECTED FILES
  ksmserver/server.cpp

To: jpalecek
Cc: plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20171106/540a51fe/attachment-0001.html>


More information about the Plasma-devel mailing list