Bug 1351655 - Log which SharedThreadPools are not yet destroyed on shutdown-threads. r=froydnj

We risk a shutdown hang without any clues if a dangling reference somewhere
keeps a SharedThreadPool alive past xpcom-shutdown-threads. This because
xpcom-shutdown-threads waits for all SharedThreadPool to be destroyed before
advancing shutdown further. nsCycleCollector::Shutdown comes after
xpcom-shutdown-threads so it is possible that a reference-cycle unexpectedly
keeps a SharedThreadPool alive and blocks shutdown indefinitely.

This patch attempts to help diagnose future cases like this by printing which
SharedThreadPools we are going to wait for to stderr.

MozReview-Commit-ID: CwTApYUMikA

--HG--
extra : rebase_source : f29d04508cf492c82d65f324d7b1990849a0da13
This commit is contained in:
Andreas Pehrson 2018-01-23 11:40:37 +01:00
Родитель 4dc16ea693
Коммит 8bb83ab05d
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -47,6 +47,19 @@ SharedThreadPoolShutdownObserver::Observe(nsISupports* aSubject, const char *aTo
const char16_t *aData)
{
MOZ_RELEASE_ASSERT(!strcmp(aTopic, "xpcom-shutdown-threads"));
#ifdef EARLY_BETA_OR_EARLIER
{
ReentrantMonitorAutoEnter mon(*sMonitor);
if (!sPools->Iter().Done()) {
nsAutoCString str;
for (auto i = sPools->Iter(); !i.Done(); i.Next()) {
str.AppendPrintf("\"%s\" ", nsAutoCString(i.Key()).get());
}
printf_stderr("SharedThreadPool in xpcom-shutdown-threads. Waiting for "
"pools %s\n", str.get());
}
}
#endif
SharedThreadPool::SpinUntilEmpty();
sMonitor = nullptr;
sPools = nullptr;