Backed out changeset 22dd9ee7e4a4 (bug 1207753) for causing bustage on ProcessHangMonitor.cpp. CLOSED TREE

This commit is contained in:
Csoregi Natalia 2022-03-22 01:31:19 +02:00
parent e780e343c7
commit 8183a2d0cd
8 changed files with 50 additions and 56 deletions

View File

@ -78,10 +78,10 @@ class ConsoleReportCollector final : public nsIConsoleReportCollector {
const CopyableTArray<nsString> mStringParams;
};
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
// protected by mMutex
nsTArray<PendingReport> mPendingReports GUARDED_BY(mMutex);
nsTArray<PendingReport> mPendingReports;
public:
NS_DECL_THREADSAFE_ISUPPORTS

View File

@ -148,28 +148,26 @@ class HangMonitorChild : public PProcessHangMonitorChild,
static Atomic<HangMonitorChild*, SequentiallyConsistent> sInstance;
const RefPtr<ProcessHangMonitor> mHangMonitor;
Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;
// Main thread-only.
bool mSentReport;
// These fields must be accessed with mMonitor held.
bool mTerminateScript GUARDED_BY(mMonitor);
bool mStartDebugger GUARDED_BY(mMonitor);
bool mFinishedStartingDebugger GUARDED_BY(mMonitor);
bool mPaintWhileInterruptingJS GUARDED_BY(mMonitor);
TabId mPaintWhileInterruptingJSTab GUARDED_BY(mMonitor);
MOZ_INIT_OUTSIDE_CTOR LayersObserverEpoch mPaintWhileInterruptingJSEpoch
GUARDED_BY(mMonitor);
bool mCancelContentJS GUARDED_BY(mMonitor);
TabId mCancelContentJSTab GUARDED_BY(mMonitor);
nsIRemoteTab::NavigationType mCancelContentJSNavigationType
GUARDED_BY(mMonitor);
int32_t mCancelContentJSNavigationIndex GUARDED_BY(mMonitor);
mozilla::Maybe<nsCString> mCancelContentJSNavigationURI GUARDED_BY(mMonitor);
int32_t mCancelContentJSEpoch GUARDED_BY(mMonitor);
JSContext* mContext GUARDED_BY(mMonitor);
bool mShutdownDone GUARDED_BY(mMonitor);
bool mTerminateScript;
bool mStartDebugger;
bool mFinishedStartingDebugger;
bool mPaintWhileInterruptingJS;
TabId mPaintWhileInterruptingJSTab;
MOZ_INIT_OUTSIDE_CTOR LayersObserverEpoch mPaintWhileInterruptingJSEpoch;
bool mCancelContentJS;
TabId mCancelContentJSTab;
nsIRemoteTab::NavigationType mCancelContentJSNavigationType;
int32_t mCancelContentJSNavigationIndex;
mozilla::Maybe<nsCString> mCancelContentJSNavigationURI;
int32_t mCancelContentJSEpoch;
JSContext* mContext;
bool mShutdownDone;
// This field is only accessed on the hang thread.
bool mIPCOpen;
@ -284,18 +282,16 @@ class HangMonitorParent : public PProcessHangMonitorParent,
// This field is only accessed on the hang thread.
bool mIPCOpen;
Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;
// Must be accessed with mMonitor held.
RefPtr<HangMonitoredProcess> mProcess GUARDED_BY(mMonitor);
bool mShutdownDone GUARDED_BY(mMonitor);
RefPtr<HangMonitoredProcess> mProcess;
bool mShutdownDone;
// Map from plugin ID to crash dump ID. Protected by
// mBrowserCrashDumpHashLock.
nsTHashMap<nsUint32HashKey, nsString> mBrowserCrashDumpIds
GUARDED_BY(mMonitor);
Mutex mBrowserCrashDumpHashLock GUARDED_BY(mMonitor);
mozilla::ipc::TaskFactory<HangMonitorParent> mMainThreadTaskFactory
GUARDED_BY(mMonitor);
nsTHashMap<nsUint32HashKey, nsString> mBrowserCrashDumpIds;
Mutex mBrowserCrashDumpHashLock MOZ_UNANNOTATED;
mozilla::ipc::TaskFactory<HangMonitorParent> mMainThreadTaskFactory;
};
} // namespace

View File

@ -20,28 +20,30 @@ namespace mozilla {
// Default reader locking strategy, using a mutex to ensure that concurrent
// PopAll calls won't overlap.
class CAPABILITY MultiWriterQueueReaderLocking_Mutex {
class MultiWriterQueueReaderLocking_Mutex {
public:
MultiWriterQueueReaderLocking_Mutex()
: mMutex("MultiWriterQueueReaderLocking_Mutex") {}
void Lock() CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); };
void Unlock() CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); };
PUSH_IGNORE_THREAD_SAFETY
void Lock() { mMutex.Lock(); };
void Unlock() { mMutex.Unlock(); };
POP_THREAD_SAFETY
private:
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
};
// Reader non-locking strategy, trusting that PopAll will never be called
// concurrently (e.g., by only calling it from a specific thread).
class CAPABILITY MultiWriterQueueReaderLocking_None {
class MultiWriterQueueReaderLocking_None {
public:
#ifndef DEBUG
void Lock() CAPABILITY_ACQUIRE(){};
void Unlock() CAPABILITY_RELEASE(){};
void Lock(){};
void Unlock(){};
#else
// DEBUG-mode checks to catch concurrent misuses.
void Lock() CAPABILITY_ACQUIRE() { MOZ_ASSERT(mLocked.compareExchange(false, true)); };
void Unlock() CAPABILITY_RELEASE() { MOZ_ASSERT(mLocked.compareExchange(true, false)); };
void Lock() { MOZ_ASSERT(mLocked.compareExchange(false, true)); };
void Unlock() { MOZ_ASSERT(mLocked.compareExchange(true, false)); };
private:
Atomic<bool> mLocked{false};

View File

@ -73,7 +73,6 @@ already_AddRefed<PerformanceStorageWorker> PerformanceStorageWorker::Create(
RefPtr<PerformanceStorageWorker> storage = new PerformanceStorageWorker();
MutexAutoLock lock(storage->mMutex); // for thread-safety analysis
storage->mWorkerRef = WeakWorkerRef::Create(
aWorkerPrivate, [storage]() { storage->ShutdownOnWorker(); });

View File

@ -37,11 +37,11 @@ class PerformanceStorageWorker final : public PerformanceStorage {
PerformanceStorageWorker();
~PerformanceStorageWorker();
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
// Protected by mutex.
// Created and released on worker-thread. Used also on main-thread.
RefPtr<WeakWorkerRef> mWorkerRef GUARDED_BY(mMutex);
RefPtr<WeakWorkerRef> mWorkerRef;
};
} // namespace dom

View File

@ -144,7 +144,7 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
// Main thread callers must hold Lock() and check CleanUp() before calling
// this. Worker thread callers, this will assert that the proxy has not been
// cleaned up.
WorkerPrivate* GetWorkerPrivate() const NO_THREAD_SAFETY_ANALYSIS;
WorkerPrivate* GetWorkerPrivate() const;
// This should only be used within WorkerRunnable::WorkerRun() running on the
// worker thread! Do not call this after calling CleanUp().
@ -156,9 +156,9 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
// 2. WorkerPromise() will crash!
void CleanUp();
Mutex& Lock() RETURN_CAPABILITY(mCleanUpLock) { return mCleanUpLock; }
Mutex& Lock() { return mCleanUpLock; }
bool CleanedUp() const REQUIRES(mCleanUpLock) {
bool CleanedUp() const {
mCleanUpLock.AssertCurrentThreadOwns();
return mCleanedUp;
}
@ -207,7 +207,7 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
const PromiseWorkerProxyStructuredCloneCallbacks* mCallbacks;
// Ensure the worker and the main thread won't race to access |mCleanedUp|.
Mutex mCleanUpLock;
Mutex mCleanUpLock MOZ_UNANNOTATED;
};
} // namespace dom
} // namespace mozilla

View File

@ -116,19 +116,18 @@ class ArrayBufferBuilder {
ArrayBufferBuilder& operator=(const ArrayBufferBuilder&) = delete;
ArrayBufferBuilder& operator=(const ArrayBufferBuilder&&) = delete;
bool SetCapacityInternal(uint32_t aNewCap, const MutexAutoLock& aProofOfLock)
REQUIRES(mMutex);
bool SetCapacityInternal(uint32_t aNewCap, const MutexAutoLock& aProofOfLock);
static bool AreOverlappingRegions(const uint8_t* aStart1, uint32_t aLength1,
const uint8_t* aStart2, uint32_t aLength2);
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
// All of these are protected by mMutex.
uint8_t* mDataPtr GUARDED_BY(mMutex);
uint32_t mCapacity GUARDED_BY(mMutex);
uint32_t mLength GUARDED_BY(mMutex);
void* mMapPtr GUARDED_BY(mMutex);
uint8_t* mDataPtr;
uint32_t mCapacity;
uint32_t mLength;
void* mMapPtr;
// This is used in assertions only.
bool mNeutered;

View File

@ -26,12 +26,10 @@ class XMLHttpRequestStringBuffer final {
return mData.Length();
}
uint32_t UnsafeLength() const NO_THREAD_SAFETY_ANALYSIS {
return mData.Length();
}
uint32_t UnsafeLength() const { return mData.Length(); }
mozilla::Result<mozilla::BulkWriteHandle<char16_t>, nsresult> UnsafeBulkWrite(
uint32_t aCapacity) NO_THREAD_SAFETY_ANALYSIS {
uint32_t aCapacity) {
return mData.BulkWrite(aCapacity, UnsafeLength(), false);
}
@ -84,10 +82,10 @@ class XMLHttpRequestStringBuffer final {
nsString& UnsafeData() { return mData; }
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
// The following member variable is protected by mutex.
nsString mData GUARDED_BY(mMutex);
nsString mData;
};
// ---------------------------------------------------------------------------