facebook/xctool — pull request #409 by ExtremeMan (2014-09-02 19:43:45+00:00)
Title: Fix issue with dispatch thread soft limit to avoid potential deadlock.

Though it is not documented but apparently there is dispatch thread soft limit on OS X (and iOS) which is equal to 64. Generation of more then 64 threads could lead to error like this: `Dispatch Thread Soft Limit: 64 reached in 2244 of 2244 samples -- too many dispatch threads blocked in synchronous operations`.

In xctool it is a semaphore which limits number of currently running threads (`jobLimiter`) which value is equal to `[[NSProcessInfo processInfo] processorCount]`. But the problem is that it doesn't limit number of created threads which could easily be more then 64. Everything would be fine if generated threads don't create other threads but it could easily happen when interaction with CoreSimulator framework happens.

So there could be a situation when there is 64 threads created to run logic tests, and every thread wants to access something in CoreSimulator frameworks which tries to dispatch another thread to guard access to shared resources but fails (locks) because there is a 64 dispatch thread soft limit. At that point all threads will be deadlocked.