[FFmpeg-devel] [PATCH] avutil: fix data race in av_get_cpu_flags()

Wan-Teh Chang wtc at google.com
Wed Dec 7 04:09:35 EET 2016


On Tue, Dec 6, 2016 at 10:41 AM, Wan-Teh Chang <wtc at google.com> wrote:
> Make the one-time initialization in av_get_cpu_flags() thread-safe. The
> static variable |cpu_flags| in libavutil/cpu.c is read and written using
> normal load and store operations. These are considered as data races.
> The fix is to use atomic load and store operations.
>
> The fix can be verified by running the libavutil/tests/cpu_init.c test
> program under ThreadSanitizer:
>     ./configure --toolchain=clang-tsan
>     make libavutil/tests/cpu_init
>     libavutil/tests/cpu_init
>
> There should be no warnings from ThreadSanitizer.
>
> Co-author: Dmitry Vyukov of Google, which suggested the data race fix.

Please ignore this patch. I just noticed that the last line of the
commit message has a grammatical error ("which" should be changed to
"who").

I will correct that and send a new patch.

Wan-Teh Chang


More information about the ffmpeg-devel mailing list