[PATCH] D15194: [safestack] Fix/port SafeStack on OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 3 08:27:46 PST 2015


kubabrecka created this revision.
kubabrecka added reviewers: eugenis, kcc, pcc, samsonov, glider.
kubabrecka added subscribers: llvm-commits, zaks.anna.

There are currently several issues/crashers with SafeStack on OS X:

1) It doesn't properly create unsafe stacks for newly created threads via pthread_create.  This should be solved by changing the runtime into a dynamic library -- see http://reviews.llvm.org/D15192.
2) It doesn't create unsafe stacks for GCD worker threads, which are not created via pthread_create.
3) Cleanup of unsafe stacks doesn't work, because the TLV holding the stack's address is already destroyed when the cleanup routine is called.

This patch implements fixes for these and adds a test for GCD.  Removing the "XFAIL: darwin" in the pthread test (which fails due to #1).  Chaning pthread-cleanup.c test to make sure we crash where we want and not somewhere else (to verify #3).

The implementation needs a workarounds for the cleanup of unsafe stack.  In unsafe_stack_free, TLVs are already destroyed.  We need to store the information about the unsafe stack elsewhere.  This patch simply malloc's a small data structure that holds there values, and stores a pointer to it in a pthread_setspecific storage.


http://reviews.llvm.org/D15194

Files:
  lib/safestack/safestack.cc
  test/safestack/Darwin/gcd.mm
  test/safestack/Darwin/lit.local.cfg
  test/safestack/pthread-cleanup.c
  test/safestack/pthread.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15194.41760.patch
Type: text/x-patch
Size: 8312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151203/912bbd5c/attachment.bin>


More information about the llvm-commits mailing list