зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1718415 - GetMainThreadIdleScheduler checks if scheduler is destroyed r=smaug
If GetMainThreadIdleScheduler is called after IPC is destroyed it can attempt to start it as if it's the first use, which crashes. Instead check if we've already destroyed the scheduler once and if so then return early. Differential Revision: https://phabricator.services.mozilla.com/D119251
This commit is contained in:
Родитель
ff55286ec5
Коммит
5cbb4adf3a
|
@ -15,10 +15,12 @@
|
|||
namespace mozilla::ipc {
|
||||
|
||||
static IdleSchedulerChild* sMainThreadIdleScheduler = nullptr;
|
||||
static bool sIdleSchedulerDestroyed = false;
|
||||
|
||||
IdleSchedulerChild::~IdleSchedulerChild() {
|
||||
if (sMainThreadIdleScheduler == this) {
|
||||
sMainThreadIdleScheduler = nullptr;
|
||||
sIdleSchedulerDestroyed = true;
|
||||
}
|
||||
MOZ_ASSERT(!mIdlePeriodState);
|
||||
}
|
||||
|
@ -112,6 +114,10 @@ IdleSchedulerChild* IdleSchedulerChild::GetMainThreadIdleScheduler() {
|
|||
return sMainThreadIdleScheduler;
|
||||
}
|
||||
|
||||
if (sIdleSchedulerDestroyed) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ipc::PBackgroundChild* background =
|
||||
ipc::BackgroundChild::GetOrCreateForCurrentThread();
|
||||
if (background) {
|
||||
|
|
|
@ -45,6 +45,8 @@ class IdleSchedulerChild final : public PIdleSchedulerChild {
|
|||
|
||||
void DoneGC();
|
||||
|
||||
// Returns nullptr if this is the parent process or the IdleSchedulerChild has
|
||||
// already been destroyed, eg if IPC is shutting down.
|
||||
static IdleSchedulerChild* GetMainThreadIdleScheduler();
|
||||
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче