Bug 1567170 - Avoid thread leak in media fuzzing target. r=jya
authorChristian Holler <choller@mozilla.com>
Thu, 22 Aug 2019 10:29:29 +0000
changeset 489404 13e2b7bfea3efa84f9420bd236517c34bd7333c0
parent 489403 a68132c5a5c39befb509d7ade7bcf0fb764eb0fb
child 489405 b1c39cc82f19fe3185dc6659594087bfc61f9032
push id36472
push usernerli@mozilla.com
push dateThu, 22 Aug 2019 15:59:04 +0000
treeherdermozilla-central@5c329d928cb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1567170
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1567170 - Avoid thread leak in media fuzzing target. r=jya Differential Revision: https://phabricator.services.mozilla.com/D41719
dom/media/fuzz/FuzzMedia.cpp
--- a/dom/media/fuzz/FuzzMedia.cpp
+++ b/dom/media/fuzz/FuzzMedia.cpp
@@ -13,16 +13,18 @@
 #include "MP4Demuxer.h"
 #include "OggDemuxer.h"
 #include "systemservices/MediaUtils.h"
 #include "WaveDemuxer.h"
 #include "WebMDemuxer.h"
 
 using namespace mozilla;
 
+RefPtr<SharedThreadPool> sFuzzThreadPool;
+
 class FuzzRunner {
  public:
   explicit FuzzRunner(Benchmark* aBenchmark) : mBenchmark(aBenchmark) {}
 
   void Run() {
     mBenchmark->Init();
     media::Await(
         GetMediaThreadPool(MediaThreadType::PLAYBACK), mBenchmark->Run(),
@@ -30,17 +32,19 @@ class FuzzRunner {
     return;
   }
 
  private:
   RefPtr<Benchmark> mBenchmark;
 };
 
 static int FuzzingInitMedia(int* argc, char*** argv) {
-  /* Generic no-op initialization used for all targets */
+  // Grab a strong reference to the media thread pool to avoid thread
+  // leaks. For more information, see bug 1567170.
+  sFuzzThreadPool = GetMediaThreadPool(MediaThreadType::PLAYBACK);
   return 0;
 }
 
 #define MOZ_MEDIA_FUZZER(_name)                                         \
   static int FuzzingRunMedia##_name(const uint8_t* data, size_t size) { \
     if (!size) {                                                        \
       return 0;                                                         \
     }                                                                   \