There are currently several issues/crashers with SafeStack on OS X:
- 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.
- It doesn't create unsafe stacks for GCD worker threads, which are not created via pthread_create.
- 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.