[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: D8673: Sanitize signal handling in ksmserver
From: Jiří Paleček <noreply () phabricator ! kde ! org>
Date: 2017-11-06 0:22:09
Message-ID: differential-rev-PHID-DREV-5xg66vfheebcuccpzihp-req () phabricator ! kde ! org
[Download RAW message or body]
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
[Attachment #3 (unknown)]
<table><tr><td style="">jpalecek created this revision.<br />Restricted Application \
added a project: Plasma.<br />Restricted Application added a subscriber: \
plasma-devel. </td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px \
8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; \
background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); \
display: inline-block; border: 1px solid rgba(71,87,120,.2);" \
href="https://phabricator.kde.org/D8673" rel="noreferrer">View \
Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>The TERM \
signal handling in ksmserver invokes functions which<br /> are not async-signal safe, \
like Qt functions and C++<br /> destructors. Moreover, the signal handling can occur \
in other than the<br /> main thread, which leads to Qt complaining about functions \
being<br /> invoked from the wrong thread. Such a crash can be seen in a report of<br \
/> "https://bugs.kde.org/show_bug.cgi?id=384316" \
<https://phabricator.kde.org/w/bug_384316/>.</p>
<p>To fix both of these issues, this change makes the signal handling use<br />
the self-pipe trick, which signals the need for termination to the<br />
main thread by writing to a special-purpose file descriptor. The main<br />
loop then takes care of the termination. This is mostly inspired by <a \
href="http://doc.qt.io/qt-5/unix-signals.html" class="remarkup-link" target="_blank" \
rel="noreferrer">http://doc.qt.io/qt-5/unix-signals.html</a>.</p>
<p>Note that <tt style="background: #ebebeb; font-size: \
13px;">QApplication::quit</tt> already does what we need when destroying<br /> the \
server, particularly deleting <tt style="background: #ebebeb; font-size: \
13px;">the_server</tt>/calling <tt style="background: #ebebeb; font-size: \
13px;">cleanUp()</tt>.</p>
<p>BTW I noticed the code (here and in XIO error handler) makes quite<br />
sure the_server is zeroed. However, other code in ksmserver is not so<br />
keen on checking <tt style="background: #ebebeb; font-size: 13px;">the_server</tt> is \
!0 when using it.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R120 \
Plasma Workspace</div></div></div><br \
/><div><strong>BRANCH</strong><div><div>Plasma/5.10</div></div></div><br \
/><div><strong>REVISION DETAIL</strong><div><a \
href="https://phabricator.kde.org/D8673" \
rel="noreferrer">https://phabricator.kde.org/D8673</a></div></div><br \
/><div><strong>AFFECTED \
FILES</strong><div><div>ksmserver/server.cpp</div></div></div><br /><div><strong>To: \
</strong>jpalecek<br /><strong>Cc: </strong>plasma-devel, ZrenBot, progwolff, \
lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart<br /></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic