summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/Signals.inc
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2016-08-24 03:42:51 +0000
committerChandler Carruth <chandlerc@gmail.com>2016-08-24 03:42:51 +0000
commiteb232dc90dc4f6950778b7cb2f31d8ce284053b2 (patch)
treecb5a18c5813b14f0933808e56b9dff818d4bdc42 /llvm/lib/Support/Unix/Signals.inc
parent3a133159cc2bda1212dd62112c7fc6146cb6f37a (diff)
downloadbcm5719-llvm-eb232dc90dc4f6950778b7cb2f31d8ce284053b2.tar.gz
bcm5719-llvm-eb232dc90dc4f6950778b7cb2f31d8ce284053b2.zip
Preserve a pointer to the newly allocated signal stack as well. That too
is flagged by LSan at least among leak detectors. llvm-svn: 279605
Diffstat (limited to 'llvm/lib/Support/Unix/Signals.inc')
-rw-r--r--llvm/lib/Support/Unix/Signals.inc10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index 6a35656c8bb..961f32b4603 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -120,11 +120,12 @@ static void RegisterHandler(int Signal) {
}
#if defined(HAVE_SIGALTSTACK)
-// Hold onto the old alternate signal stack so that it's not reported as a leak.
-// We don't make any attempt to remove our alt signal stack if we remove our
-// signal handlers; that can't be done reliably if someone else is also trying
-// to do the same thing.
+// Hold onto both the old and new alternate signal stack so that it's not
+// reported as a leak. We don't make any attempt to remove our alt signal
+// stack if we remove our signal handlers; that can't be done reliably if
+// someone else is also trying to do the same thing.
static stack_t OldAltStack;
+static void* NewAltStackPointer;
static void CreateSigAltStack() {
const size_t AltStackSize = MINSIGSTKSZ + 64 * 1024;
@@ -140,6 +141,7 @@ static void CreateSigAltStack() {
stack_t AltStack = {};
AltStack.ss_sp = reinterpret_cast<char *>(malloc(AltStackSize));
+ NewAltStackPointer = AltStack.ss_sp; // Save to avoid reporting a leak.
AltStack.ss_size = AltStackSize;
if (sigaltstack(&AltStack, &OldAltStack) != 0)
free(AltStack.ss_sp);
OpenPOWER on IntegriCloud