diff options
author | Steven Wu <stevenwu@apple.com> | 2015-05-07 16:20:51 +0000 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2015-05-07 16:20:51 +0000 |
commit | 94746694ca70606a08f45c5db4f423cbe632ae37 (patch) | |
tree | 7affa429b12fe4e9f7da950bed5117f698b78d23 /llvm/lib/Support/Unix/Signals.inc | |
parent | a9f6d3505d04aec6849a8309ce7e1971c0c142cb (diff) | |
download | bcm5719-llvm-94746694ca70606a08f45c5db4f423cbe632ae37.tar.gz bcm5719-llvm-94746694ca70606a08f45c5db4f423cbe632ae37.zip |
Fix another hang caused by ManagedStatic in SignalHandler
Fix two other variables that might cause the same hang fixed in r235914.
The hang is caused by constructing ManagedStatic in signalhandler. In
this case, if FileToRemove or CallBacksToRun is not contructed, it means
there is no work to do.
llvm-svn: 236741
Diffstat (limited to 'llvm/lib/Support/Unix/Signals.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Signals.inc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index e7696c2f7ee..26fd5c3f4e6 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -139,6 +139,11 @@ static void UnregisterHandlers() { /// NB: This must be an async signal safe function. It cannot allocate or free /// memory, even in debug builds. static void RemoveFilesToRemove() { + // Avoid constructing ManagedStatic in the signal handler. + // If FilesToRemove is not constructed, there are no files to remove. + if (!FilesToRemove.isConstructed()) + return; + // We avoid iterators in case of debug iterators that allocate or release // memory. std::vector<std::string>& FilesToRemoveRef = *FilesToRemove; @@ -200,10 +205,12 @@ static RETSIGTYPE SignalHandler(int Sig) { } // Otherwise if it is a fault (like SEGV) run any handler. - std::vector<std::pair<void (*)(void *), void *>>& CallBacksToRunRef = - *CallBacksToRun; - for (unsigned i = 0, e = CallBacksToRun->size(); i != e; ++i) - CallBacksToRunRef[i].first(CallBacksToRunRef[i].second); + if (CallBacksToRun.isConstructed()) { + std::vector<std::pair<void (*)(void *), void *>>& CallBacksToRunRef = + *CallBacksToRun; + for (unsigned i = 0, e = CallBacksToRun->size(); i != e; ++i) + CallBacksToRunRef[i].first(CallBacksToRunRef[i].second); + } #ifdef __s390__ // On S/390, certain signals are delivered with PSW Address pointing to |