1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-08-03 17:59:59 +02:00
ffmpeg/libavutil/tests
Wan-Teh Chang 2170017a1c avutil: fix data race in av_get_cpu_flags()
Make the one-time initialization in av_get_cpu_flags() thread-safe. The
static variables |flags|, |cpuflags_mask|, and |checked| in
libavutil/cpu.c are 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.

Remove the |checked| variable because the invalid value of -1 for
|flags| can be used to indicate the same condition. Rename |flags| to
|cpu_flags| and move it to file scope.

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, who suggested the data race fix.

Signed-off-by: Wan-Teh Chang <wtc@google.com>
2016-12-08 15:53:58 -05:00
..
.gitignore avutil: fix data race in av_get_cpu_flags() 2016-12-08 15:53:58 -05:00
adler32.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
aes.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
avstring.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
base64.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
blowfish.c blowfish-test: Use struct allocation functions from the API 2016-05-19 09:55:55 +02:00
cpu_init.c avutil: fix data race in av_get_cpu_flags() 2016-12-08 15:53:58 -05:00
cpu.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
crc.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
des.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
eval.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
fifo.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
float_dsp.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
hmac.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
lfg.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
lls.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
md5.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
opt.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
parseutils.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
sha.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
tree.c tests: Move all test programs to a subdirectory 2016-05-13 14:55:56 +02:00
xtea.c xtea-test: Use struct allocation functions from the API 2016-05-19 09:55:55 +02:00