Bug 1472889: Work around sporadic automation failures on Linux. r?erahm
MozReview-Commit-ID: 1FrxRm95lqE
--- a/dom/ipc/MemMapSnapshot.cpp
+++ b/dom/ipc/MemMapSnapshot.cpp
@@ -113,17 +113,29 @@ MemMapSnapshot::Freeze(AutoMemMap& aMem)
// since we open and share a read-only file descriptor, and then delete the
// file. But it doesn't hurt, either.
chmod(mPath.get(), 0400);
nsCOMPtr<nsIFile> file;
MOZ_TRY(NS_NewNativeLocalFile(mPath, /* followLinks = */ false,
getter_AddRefs(file)));
- return aMem.init(file);
+ auto result = aMem.init(file);
+#ifdef XP_LINUX
+ // On Linux automation runs, every few hundred thousand calls, our attempt to
+ // stat the file that we just successfully opened fails with EBADF (bug
+ // 1472889). Presumably this is a race with a background thread that double
+ // closes a file, but is difficult to diagnose, so work around it by making a
+ // second mapping attempt if the first one fails.
+ if (!result.isOk()) {
+ aMem.reset();
+ result = aMem.init(file);
+ }
+#endif
+ return result;
}
#else
# error "Unsupported build configuration"
#endif
} // namespace ipc
} // namespace mozilla