From c2e9cb1c302ef6670741cc89c4f9465e8718f6ad Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Sat, 10 Jan 2015 12:41:48 -0500 Subject: [PATCH] Bug 1113416 - Don't read stack labels inside hang monitor sighandler; r=nfroyd r=snorp When we're inside the hang monitor's signal handler, we must not read any string labels. Doing so may result in on-demand decompression kicking in on Android, which may result in a deadlock. --- xpcom/threads/BackgroundHangMonitor.cpp | 7 +++++++ xpcom/threads/ThreadStackHelper.cpp | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/xpcom/threads/BackgroundHangMonitor.cpp b/xpcom/threads/BackgroundHangMonitor.cpp index 44f4bce50642..af1592ee2aea 100644 --- a/xpcom/threads/BackgroundHangMonitor.cpp +++ b/xpcom/threads/BackgroundHangMonitor.cpp @@ -360,6 +360,13 @@ BackgroundHangThread::ReportHang(PRIntervalTime aHangTime) // Recovered from a hang; called on the monitor thread // mManager->mLock IS locked + // Remove unwanted "js::RunScript" frame from the stack + for (const char** f = &mHangStack.back(); f >= mHangStack.begin(); f--) { + if (!mHangStack.IsInBuffer(*f) && !strcmp(*f, "js::RunScript")) { + mHangStack.erase(f); + } + } + Telemetry::HangHistogram newHistogram(Move(mHangStack)); for (Telemetry::HangHistogram* oldHistogram = mStats.mHangs.begin(); oldHistogram != mStats.mHangs.end(); oldHistogram++) { diff --git a/xpcom/threads/ThreadStackHelper.cpp b/xpcom/threads/ThreadStackHelper.cpp index 3e57d17dafb2..07a8e2dd7cc7 100644 --- a/xpcom/threads/ThreadStackHelper.cpp +++ b/xpcom/threads/ThreadStackHelper.cpp @@ -673,10 +673,8 @@ ThreadStackHelper::FillStackBuffer() } #endif const char* const label = entry->label(); - if (mStackToFill->IsSameAsEntry(prevLabel, label) || - !strcmp(label, "js::RunScript")) { + if (mStackToFill->IsSameAsEntry(prevLabel, label)) { // Avoid duplicate labels to save space in the stack. - // Avoid js::RunScript labels because we save actual JS frames above. continue; } mStackToFill->infallibleAppend(label);