facebook/xctool — pull request #260 by fpotter (2013-11-22 23:13:23+00:00)
Title: fix for the race condition bug in `-[SenTestClassEnumerator init]`

The implementation for `-[SenTestClassEnumerator init]` uses objc_getClassList
to retrieve the list of Obj-C classes. It first calls objc_getClassList to
get the count of classes, then allocates a buffer of that size, then calls
objc_getClassList again to retrieve all the classes (and that's the problem).

In between `-[SenTestClassEnumerator init]`'s two calls to objc_getClassList,
background threads can trigger more classes to be registered. Unfortunately,
the implementation throws an exception if the two counts returned by
objc_getClassList don't match.

Let's swizzle `init` and provide our own impementation that uses
objc_copyClassList instead, which will return the class list in one shot.
This is exactly what XCTest now does.

Closes #257