Description
Previous ID | SR-2655 |
Radar | None |
Original Reporter | @weissi |
Type | Bug |
Status | Resolved |
Resolution | Done |
Attachment: Download
Additional Detail from JIRA
Votes | 0 |
Component/s | libdispatch |
Labels | Bug, Linux |
Assignee | dgrove-oss (JIRA) |
Priority | Medium |
md5: 071933e7988663468728927c7cfe2cd7
Issue Description:
Description
Certain signals are masked/blocked on libdispatch/libpwq worker threads.
On Darwin, the list of masked signals is the inverse of workq_threadmask
:
#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP))
#define threadmask (sigmask(SIGILL)|sigmask(SIGTRAP)|\
sigmask(SIGIOT)|sigmask(SIGEMT)|\
sigmask(SIGFPE)|sigmask(SIGBUS)|\
sigmask(SIGSEGV)|sigmask(SIGSYS)|\
sigmask(SIGPIPE)|sigmask(SIGKILL))
#define workq_threadmask (threadmask | sigcantmask)
There is actually a function _dispatch_pthread_sigmask
which given a full sigmask calculates a similiar sigmask which is then used in certain situations.
However, the overcommit_worker_main
function in libpwq
chooses to mask all the signals which doesn't seem correct. To fix this issue, it seems enough to only block the signals _dispatch_pthread_sigmask
elects instead of all.
There is also another place in libpwq
where all signals are blocked on a thread. I'm unsure whether that is correct.
Repro
Running the attached test.c
shows the problem:
Darwin
Darwin jwmbp.local 16.0.0 Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:21 PDT 2016; root:xnu-3789.1.32~3/DEVELOPMENT_X86_64 x86_64
main
====
dispatch
=======
dispatch: SIGHUP is BLOCKED
dispatch: SIGINT is BLOCKED
dispatch: SIGQUIT is BLOCKED
dispatch: SIGALRM is BLOCKED
dispatch: SIGTERM is BLOCKED
dispatch: SIGURG is BLOCKED
dispatch: SIGTSTP is BLOCKED
dispatch: SIGCONT is BLOCKED
dispatch: SIGCHLD is BLOCKED
dispatch: SIGTTIN is BLOCKED
dispatch: SIGTTOU is BLOCKED
dispatch: SIGIO is BLOCKED
dispatch: SIGXCPU is BLOCKED
dispatch: SIGXFSZ is BLOCKED
dispatch: SIGVTALRM is BLOCKED
dispatch: SIGWINCH is BLOCKED
dispatch: SIGUSR1 is BLOCKED
dispatch: SIGUSR2 is BLOCKED
pthread
=======
Linux
libdispatch
@ https://github.com/apple/swift-corelibs-libdispatch/tree/7fe8323838b0491691e515a7f826ffe508668856 ish
Linux build 4.4.0-36-generic #​55-Ubuntu SMP Thu Aug 11 18:01:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
main
====
dispatch
=======
dispatch: SIGHUP is BLOCKED
dispatch: SIGINT is BLOCKED
dispatch: SIGQUIT is BLOCKED
dispatch: SIGILL is BLOCKED
dispatch: SIGTRAP is BLOCKED
dispatch: SIGABRT is BLOCKED
dispatch: SIGIOT is BLOCKED
dispatch: SIGFPE is BLOCKED
dispatch: SIGBUS is BLOCKED
dispatch: SIGSEGV is BLOCKED
dispatch: SIGSYS is BLOCKED
dispatch: SIGPIPE is BLOCKED
dispatch: SIGALRM is BLOCKED
dispatch: SIGTERM is BLOCKED
dispatch: SIGURG is BLOCKED
dispatch: SIGTSTP is BLOCKED
dispatch: SIGCONT is BLOCKED
dispatch: SIGCHLD is BLOCKED
dispatch: SIGTTIN is BLOCKED
dispatch: SIGTTOU is BLOCKED
dispatch: SIGIO is BLOCKED
dispatch: SIGXCPU is BLOCKED
dispatch: SIGXFSZ is BLOCKED
dispatch: SIGVTALRM is BLOCKED
dispatch: SIGPROF is BLOCKED
dispatch: SIGWINCH is BLOCKED
dispatch: SIGUSR1 is BLOCKED
dispatch: SIGUSR2 is BLOCKED
pthread
=======