[llvm] r235914 - Fixes a hang that can occur if a signal comes in during malloc calls.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Apr 27 15:04:05 PDT 2015


Thanks!

On 27 April 2015 at 17:57, Chris Bieneman <beanz at apple.com> wrote:
> Almost definitely.
>
> -Chris
>
>> On Apr 27, 2015, at 2:56 PM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
>>
>> Does this fix pr22272?
>>
>> On 27 April 2015 at 16:45, Chris Bieneman <beanz at apple.com> wrote:
>>> Author: cbieneman
>>> Date: Mon Apr 27 15:45:35 2015
>>> New Revision: 235914
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=235914&view=rev
>>> Log:
>>> 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.
>>>
>>> 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=235914&r1=235913&r2=235914&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/lib/Support/Unix/Signals.inc (original)
>>> +++ llvm/trunk/lib/Support/Unix/Signals.inc Mon Apr 27 15:45:35 2015
>>> @@ -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;
>>>
>>>
>>>
>>> _______________________________________________
>>> 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