This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by EricWF on Oct 14 2015, 3:20 PM.

Details

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

Diff Detail

Event Timeline

EricWF updated this revision to Diff 37399.Oct 14 2015, 3:20 PM
EricWF retitled this revision from to [libcxx] Fix PR15638 - Only allocate in parent when starting a thread to prevent calling terminate..
EricWF updated this object.
EricWF added reviewers: mclow.lists, danalbert, jroelofs.
EricWF added a subscriber: cfe-commits.
EricWF accepted this revision.Apr 19 2016, 7:25 PM
EricWF added a reviewer: EricWF.

Accepting.

This revision is now accepted and ready to land.Apr 19 2016, 7:25 PM
EricWF closed this revision.Apr 19 2016, 7:27 PM