Bug 973353: Disable IOInterposer when reporting a crash; r=froydnj,ted

This commit is contained in:
Aaron Klotz
2014-03-15 00:10:39 -06:00
parent de8e7422bb
commit 0b03b70a55
3 changed files with 34 additions and 13 deletions

View File

@@ -7,6 +7,7 @@
#include "IOInterposer.h"
#include "mozilla/Atomics.h"
#include "mozilla/Mutex.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/ThreadLocal.h"
@@ -23,8 +24,9 @@ namespace {
/** Lists of Observers */
struct ObserverLists {
ObserverLists()
: mObserverListsLock(PR_NewLock())
, mIsEnabled(true)
{
mObserverListsLock = PR_NewLock();
// We don't do MOZ_COUNT_CTOR(ObserverLists) as we will need to leak the
// IO interposer when doing late-write checks, which uses IO interposing
// to check for writes while static destructors are invoked.
@@ -38,6 +40,9 @@ struct ObserverLists {
// during shutdown.
PRLock* mObserverListsLock;
// Used for quickly disabling everything by IOInterposer::Disable()
mozilla::Atomic<bool> mIsEnabled;
~ObserverLists()
{
PR_DestroyLock(mObserverListsLock);
@@ -185,6 +190,15 @@ IOInterposeObserver::IsMainThread()
}
}
/* static */ void
IOInterposer::Disable()
{
if (!sObserverLists) {
return;
}
sObserverLists->mIsEnabled = false;
}
/* static */ void IOInterposer::Report(
IOInterposeObserver::Observation& aObservation)
{
@@ -254,6 +268,13 @@ IOInterposeObserver::IsMainThread()
}
}
/* static */ bool
IOInterposer::IsObservedOperation(IOInterposeObserver::Operation aOp)
{
return sObserverLists && sObserverLists->mIsEnabled &&
!!(sObservedOperations & aOp);
}
/* static */ void IOInterposer::Register(IOInterposeObserver::Operation aOp,
IOInterposeObserver* aObserver)
{