Commit c0873d79 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Fix the data race of VideoTrackRecorder::Encoder::pause_

|pause_| can be set on the main thread and read on the io thread
at the same time. Declaring |pause_| as an atomic variable
solves the data race problem.

Fuzzer report: https://clusterfuzz.com/testcase?key=5766664522432512

Bug: 988327
Change-Id: Idd43e9d932dc96900b46a09c8b46ba4337505880
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722952
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682194}
parent ecb04863
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_VIDEO_TRACK_RECORDER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_VIDEO_TRACK_RECORDER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_VIDEO_TRACK_RECORDER_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_VIDEO_TRACK_RECORDER_H_
#include <atomic>
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
...@@ -204,7 +205,9 @@ class MODULES_EXPORT VideoTrackRecorder ...@@ -204,7 +205,9 @@ class MODULES_EXPORT VideoTrackRecorder
// While |paused_|, frames are not encoded. Used only from // While |paused_|, frames are not encoded. Used only from
// |encoding_thread_|. // |encoding_thread_|.
bool paused_; // Use an atomic variable since it can be set on the main thread and read
// on the io thread at the same time.
std::atomic_bool paused_;
// This callback should be exercised on IO thread. // This callback should be exercised on IO thread.
const OnEncodedVideoCB on_encoded_video_callback_; const OnEncodedVideoCB on_encoded_video_callback_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment