Bug 1734262 - Suppress thread leak reports for the monitor thread. r=decoder

For the same reasons discussed in the previous commit, it's impractical
to join these threads on shutdown, and so we should suppress thread leak
reports for them.

Differential Revision: https://phabricator.services.mozilla.com/D128651
This commit is contained in:
Bobby Holley 2021-10-16 16:29:32 +00:00
parent 066888880d
commit 041a1558be
3 changed files with 21 additions and 3 deletions

View File

@ -205,6 +205,14 @@ extern "C" const char* __tsan_default_suppressions() {
// trigger OS-level paging. It is never joined with the main thread.
"thread:StartupCache\n"
// Bug 1734262 - Permanent
// When spawning async processes, we create a helper thread to wait for
// the process to terminate in order to asynchronously report the exit
// code to Gecko. This thread waits on a syscall for the process to end,
// which means there's no easy way to cancel and join it during Gecko
// shutdown. Suppress thread leak reports for this thread.
"thread:CreateMonitorThread\n"
// Bug 1601600
"race:SkARGB32_Blitter\n"
"race:SkARGB32_Shader_Blitter\n"

View File

@ -44,6 +44,7 @@ class nsProcess final : public nsIProcess, public nsIObserver {
private:
~nsProcess();
PRThread* CreateMonitorThread();
static void Monitor(void* aArg);
void ProcessComplete();
nsresult CopyArgsAndRunProcess(bool aBlocking, const char** aArgs,

View File

@ -429,9 +429,7 @@ nsresult nsProcess::RunProcess(bool aBlocking, char** aMyArgv,
return NS_ERROR_FILE_EXECUTION_FAILED;
}
} else {
mThread =
PR_CreateThread(PR_SYSTEM_THREAD, Monitor, this, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
mThread = CreateMonitorThread();
if (!mThread) {
NS_RELEASE_THIS();
return NS_ERROR_FAILURE;
@ -447,6 +445,17 @@ nsresult nsProcess::RunProcess(bool aBlocking, char** aMyArgv,
return NS_OK;
}
// We don't guarantee that monitor threads are joined before Gecko exits, which
// can cause TSAN to complain about thread leaks. We handle this with a TSAN
// suppression, and route thread creation through this helper so that the
// suppression is as narrowly-scoped as possible.
PRThread*
nsProcess::CreateMonitorThread()
{
return PR_CreateThread(PR_SYSTEM_THREAD, Monitor, this, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
}
NS_IMETHODIMP
nsProcess::GetIsRunning(bool* aIsRunning) {
if (mThread) {