From 556c152c54e20ae1173e565720341f6fe3f8590e Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 13 Dec 2012 19:42:47 -0800 Subject: [PATCH] Bug 821577 - DMD: Fix hang at start-up on Mac. r=jlebar. --HG-- extra : rebase_source : 39b46f3a7b8aead6e971f55cb0821f443b7368dc --- memory/replace/dmd/DMD.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index f78424ac4c10..8e62ec6fd34a 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -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_(); gSmallBlockActualSizeCounter = 0;