Bug 1008254 - Allow Nuwa's global sAllThreads list to be non-empty on exit, to green a near-permanent orange on B2G mochitest-9 - r=khuey

This commit is contained in:
Benoit Jacob 2014-07-02 16:40:29 -04:00
parent 25279c0512
commit 9f5549e2d3

View File

@ -199,9 +199,47 @@ static TLSKeySet sTLSKeys;
static pthread_mutex_t sThreadFreezeLock = PTHREAD_MUTEX_INITIALIZER;
static thread_info_t sMainThread;
static LinkedList<thread_info_t> sAllThreads;
static int sThreadCount = 0;
static int sThreadFreezeCount = 0;
// Bug 1008254: LinkedList's destructor asserts that the list is empty.
// But here, on exit, when the global sAllThreads list
// is destroyed, it may or may be empty. Bug 1008254 comment 395 has a log
// when there were 8 threads remaining on exit. So this assertion was
// intermittently (almost every second time) failing.
// As a work-around to avoid this intermittent failure, we clear the list on
// exit just before it gets destroyed. This is the only purpose of that
// AllThreadsListType subclass.
struct AllThreadsListType : public LinkedList<thread_info_t>
{
~AllThreadsListType()
{
if (!isEmpty()) {
__android_log_print(ANDROID_LOG_WARN, "Nuwa",
"Threads remaining at exit:\n");
int n = 0;
for (const thread_info_t* t = getFirst(); t; t = t->getNext()) {
__android_log_print(ANDROID_LOG_WARN, "Nuwa",
" %.*s (origNativeThreadID=%d recreatedNativeThreadID=%d)\n",
NATIVE_THREAD_NAME_LENGTH,
t->nativeThreadName,
t->origNativeThreadID,
t->recreatedNativeThreadID);
n++;
}
__android_log_print(ANDROID_LOG_WARN, "Nuwa",
"total: %d outstanding threads. "
"Please fix them so they're destroyed before this point!\n", n);
__android_log_print(ANDROID_LOG_WARN, "Nuwa",
"note: sThreadCount=%d, sThreadFreezeCount=%d\n",
sThreadCount,
sThreadFreezeCount);
}
clear();
}
};
static AllThreadsListType sAllThreads;
/**
* This mutex protects the access to thread info:
* sAllThreads, sThreadCount, sThreadFreezeCount, sRecreateVIPCount.