Bug 821577 - DMD: Fix hang at start-up on Mac. r=jlebar.

--HG--
extra : rebase_source : 39b46f3a7b8aead6e971f55cb0821f443b7368dc
This commit is contained in:
Nicholas Nethercote 2012-12-13 19:42:47 -08:00
parent 42a5e1417d
commit 556c152c54

View File

@ -1637,6 +1637,13 @@ BadArg(const char* aArg)
exit(1);
}
#ifdef XP_MACOSX
static void
NopStackWalkCallback(void* aPc, void* aSp, void* aClosure)
{
}
#endif
// Note that fopen() can allocate.
static FILE*
OpenTestOrStressFile(const char* aFilename)
@ -1729,6 +1736,16 @@ Init(const malloc_table_t* aMallocTable)
StatusMsg("DMD is enabled\n");
#ifdef XP_MACOSX
// On Mac OS X we need to call StackWalkInitCriticalAddress() very early
// (prior to the creation of any mutexes, apparently) otherwise we can get
// hangs when getting stack traces (bug 821577). But
// StackWalkInitCriticalAddress() isn't exported from xpcom/, so instead we
// just call NS_StackWalk, because that calls StackWalkInitCriticalAddress().
// See the comment above StackWalkInitCriticalAddress() for more details.
(void)NS_StackWalk(NopStackWalkCallback, 0, nullptr, 0, nullptr);
#endif
gStateLock = InfallibleAllocPolicy::new_<Mutex>();
gSmallBlockActualSizeCounter = 0;