From dbaf039dde35606b295836381e71a5a69aef802e Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Mon, 27 Apr 2015 20:45:35 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235914 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Unix/Signals.inc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc index 057bcab1600..e7696c2f7ee 100644 --- a/lib/Support/Unix/Signals.inc +++ b/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;