Fix crashes caused by failing to unlock or destroy a static mutex while the app is being terminated (#577)

* Fix crashes caused by failing to unlock or destroy a static mutex while the app is being terminated

* Allocate static mutexes on the heap memory to avoid destruction at app exit

* ASThread to use ASDisplayNodeCAssert() instead of assert()
This commit is contained in:
Huy Nguyen
2017-09-22 11:53:41 +01:00
committed by GitHub
parent 76eccbf269
commit 8e0aa1ea73
7 changed files with 34 additions and 33 deletions

View File

@@ -40,8 +40,9 @@
{
if (self = [super init]) {
// Concurrently initialising TextKit components crashes (rdar://18448377) so we use a global lock.
static ASDN::Mutex __staticMutex;
ASDN::MutexLocker l(__staticMutex);
// Allocate __staticMutex on the heap to prevent destruction at app exit (https://github.com/TextureGroup/Texture/issues/136)
static ASDN::StaticMutex& __staticMutex = *new ASDN::StaticMutex;
ASDN::StaticMutexLocker l(__staticMutex);
__instanceLock__ = std::make_shared<ASDN::Mutex>();