[llvm] r236741 - Fix another hang caused by ManagedStatic in SignalHandler
Steven Wu
stevenwu at apple.com
Thu May 7 13:00:18 PDT 2015
> On May 7, 2015, at 11:29 AM, Justin Bogner <mail at justinbogner.com> wrote:
>
> Steven Wu <stevenwu at apple.com> writes:
>> Author: steven_wu
>> Date: Thu May 7 11:20:51 2015
>> New Revision: 236741
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=236741&view=rev
>> Log:
>> 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.
>>
>> Modified:
>> llvm/trunk/lib/Support/Unix/Signals.inc
>>
>> Modified: llvm/trunk/lib/Support/Unix/Signals.inc
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Signals.inc?rev=236741&r1=236740&r2=236741&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Support/Unix/Signals.inc (original)
>> +++ llvm/trunk/lib/Support/Unix/Signals.inc Thu May 7 11:20:51 2015
>> @@ -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;
>
> This looks like a job for "auto &”.
Ok. Agree. Commit in r236768.
>
>> + 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
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list