From 345531a4cea1817fcc22bc95fed9d96adf0f54c9 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 22 Apr 2015 15:32:43 -0700 Subject: [PATCH] Bug 1157488 - Assert against re-entrant sync sections. r=bent --- widget/nsBaseAppShell.cpp | 7 +++++++ widget/nsBaseAppShell.h | 1 + 2 files changed, 8 insertions(+) diff --git a/widget/nsBaseAppShell.cpp b/widget/nsBaseAppShell.cpp index aa6468554b99..be813c6b735f 100644 --- a/widget/nsBaseAppShell.cpp +++ b/widget/nsBaseAppShell.cpp @@ -31,6 +31,7 @@ nsBaseAppShell::nsBaseAppShell() , mSwitchTime(0) , mLastNativeEventTime(0) , mEventloopNestingState(eEventloopNone) + , mRunningSyncSections(false) , mRunning(false) , mExiting(false) , mBlockNativeEvent(false) @@ -350,6 +351,11 @@ nsBaseAppShell::RunSyncSectionsInternal(bool aStable, NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(!mSyncSections.IsEmpty(), "Nothing to do!"); + // We don't support re-entering sync sections. This effectively means that + // sync sections may not spin the event loop. + MOZ_RELEASE_ASSERT(!mRunningSyncSections); + mRunningSyncSections = true; + // We've got synchronous sections. Run all of them that are are awaiting a // stable state if aStable is true (i.e. we really are in a stable state). // Also run the synchronous sections that are simply waiting for the right @@ -377,6 +383,7 @@ nsBaseAppShell::RunSyncSectionsInternal(bool aStable, } mSyncSections.SwapElements(pendingSyncSections); + mRunningSyncSections = false; } void diff --git a/widget/nsBaseAppShell.h b/widget/nsBaseAppShell.h index b2b9479ecbfe..b528e88e484a 100644 --- a/widget/nsBaseAppShell.h +++ b/widget/nsBaseAppShell.h @@ -134,6 +134,7 @@ private: }; EventloopNestingState mEventloopNestingState; nsTArray mSyncSections; + bool mRunningSyncSections; bool mRunning; bool mExiting; /**