]> granicus.if.org Git - llvm/commit
[Support] Avoid concurrency hazard in signal handler registration
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Mon, 27 Mar 2017 18:21:31 +0000 (18:21 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Mon, 27 Mar 2017 18:21:31 +0000 (18:21 +0000)
commitfa92ec8e9e59d57a1556ec7b2024de94001485ae
tree6f934fa546cde4b93de90b768db63dea5a3cd6c4
parent0532ee926c28ac0abda1d4181123974ec6bd1507
[Support] Avoid concurrency hazard in signal handler registration

Several static functions from the signal API can be invoked
simultaneously; RemoveFileOnSignal for instance can be called indirectly
by multiple parallel loadModule() invocations, which might lead to
the assertion:

Assertion failed: (NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) && "Out of space for signal handlers!"),
  function RegisterHandler, file /llvm/lib/Support/Unix/Signals.inc, line 105.

RemoveFileOnSignal calls RegisterHandlers(), which isn't currently
mutex protected, leading to the behavior above. This potentially affect
a few other users of RegisterHandlers() too.

rdar://problem/30381224

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298871 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/Unix/Signals.inc