diff options
author | Chris Bieneman <beanz@apple.com> | 2015-04-27 20:45:35 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2015-04-27 20:45:35 +0000 |
commit | 017ebf09d97e209a4d228be8ab24582251ac025f (patch) | |
tree | 3cc6fa8aabbe60f17b580650f97eaa26d58962e3 /llvm/lib/Support/Unix/Signals.inc | |
parent | e71db85beda3b82ad9aaf38c5eba9212e53a7071 (diff) | |
download | llvm-017ebf09d97e209a4d228be8ab24582251ac025f.zip llvm-017ebf09d97e209a4d228be8ab24582251ac025f.tar.gz llvm-017ebf09d97e209a4d228be8ab24582251ac025f.tar.bz2 |
Fixes a hang that can occur if a signal comes in during malloc calls.
We need to dereference the signals mutex during handler registration so that we force its construction. This is to prevent the first use being during handling an actual signal because you can't safely allocate memory in a signal handler.
llvm-svn: 235914
Diffstat (limited to 'llvm/lib/Support/Unix/Signals.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Signals.inc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 057bcab1..e7696c2 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -112,6 +112,12 @@ static void RegisterHandler(int Signal) { } static void RegisterHandlers() { + // We need to dereference the signals mutex during handler registration so + // that we force its construction. This is to prevent the first use being + // during handling an actual signal because you can't safely call new in a + // signal handler. + *SignalsMutex; + // If the handlers are already registered, we're done. if (NumRegisteredSignals != 0) return; |