[libcxx] Fix PR15638 - Only allocate in parent when starting a thread to prevent calling terminate.

Summary:
Hi,

When creating a new thread libc++ performs at least 2 allocations. The first allocates a tuple of args and the functor that will be passed to the new thread. The second allocation is for the thread local storage needed internally by libc++. Currently the second allocation happens in the child thread, meaning that if it throws the program will terminate with an uncaught bad alloc.

The solution to this is to allocate ALL memory in the parent thread and then pass it to the child.

See https://llvm.org/bugs/show_bug.cgi?id=15638

Reviewers: mclow.lists, danalbert, jroelofs, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13748

llvm-svn: 266851
GitOrigin-RevId: e08afaf8df5ff65a4d89d85dc923456bc5131151
2 files changed