Merge lp://staging/~zyga/checkbox/fix-1402421 into lp://staging/checkbox

Proposed by Zygmunt Krynicki
Status: Work in progress
Proposed branch: lp://staging/~zyga/checkbox/fix-1402421
Merge into: lp://staging/checkbox
Diff against target: 239 lines (+67/-28)
3 files modified
plainbox/plainbox/vendor/extcmd/glibc.py (+2/-2)
plainbox/plainbox/vendor/pyglibc/__init__.py (+2/-0)
plainbox/plainbox/vendor/pyglibc/_pthread_sigmask.py (+63/-26)
To merge this branch: bzr merge lp://staging/~zyga/checkbox/fix-1402421
Reviewer Review Type Date Requested Status
Checkbox Developers Pending
Review via email: mp+244707@code.staging.launchpad.net

Description of the change

NOTE: needs testing in real-world situation

edb5146 plainbox:vendor:glibc: refactor pthread_sigmask
a498cb3 plainbox:vendor:glibc: add sigprocmask
ac9f454 plainbox:vendor:glibc: fix man page ref for pthread_sigmask
ed40c72 plainbox:vendor:extcmd use process-wide signal masks

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Unmerged revisions

3507. By Zygmunt Krynicki

plainbox:vendor:extcmd use process-wide signal masks

This patch changes extcmd to use process-wide signal masks (aka
sigprocmask vs pthread_sigmask). This fixes a problem where in a
multi-threaded application, extcmd might misbehave if the SIGCHLD signal
was delivered to a different thread than the one running extcmd's event
loop. When that happens the signal itself is consumed and subsequent
read from signalfd() would return EAGAIN (aka errno 11, aka
BlockingIOError).

The precise sequence of events that need to happen in
order to trigger this bug is:

- assume that there is a process P1, running two threads T1 and T2.
  Extcmd is running in T1 and has blocked SIGCHLD (so that it can be
  collected via epoll-triggered signalfd). T2 runs unrelated code.
- assume that there is a process P2, that is a child of P1, that has
  just exited.
- the signal is enqueued as readable via signalfd, waking up T1
- since P1's T1 is blocking SIGCHLD, the signal is delivered to T2.
- T1 tries to read() from signalfd and receives EAGAIN

The patch fixes this so that no matter how the scheduling orders events,
this will happen:

- assume that there is a process P1, running two threads T1 and T2.
  Extcmd is running in T1 and has blocked SIGCHLD (so that it can be
  collected via epoll-triggered signalfd). T2 runs unrelated code.
- assume that there is a process P2, that is a child of P1, that has
  just exited.
- the signal is enqueued as readable via signalfd, waking up T1
- since P1 is blocking SIGCHLD for all threads the signal is not
  delivered
- T1 reads signal details from signalfd

Fixes: https://bugs.launchpad.net/plainbox/+bug/1402421

Signed-off-by: Zygmunt Krynicki <email address hidden>

3506. By Zygmunt Krynicki

plainbox:vendor:glibc: fix man page ref for pthread_sigmask

Signed-off-by: Zygmunt Krynicki <email address hidden>

3505. By Zygmunt Krynicki

plainbox:vendor:glibc: add sigprocmask

This patch adds a trivial implementation of sigprocmask, based on
_sigxxxmask_base. This allows one to use either process-wide or
per-thread signal blocks using the same API.

Signed-off-by: Zygmunt Krynicki <email address hidden>

3504. By Zygmunt Krynicki

plainbox:vendor:glibc: refactor pthread_sigmask

This patch refactors the pthread_sigmaks into a generic base class
_sigxxxmask_base that can now be used to trivially implement
pthread_sigmask and, in the upcoming patch, sigprocmask.

Signed-off-by: Zygmunt Krynicki <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches