• Wan-Teh Chang's avatar
    avutil: fix data race in av_get_cpu_flags() · 2170017a
    Wan-Teh Chang authored
    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: 's avatarWan-Teh Chang <wtc@google.com>
    2170017a
Name
Last commit
Last update
..
aac.mak Loading commit data...
ac3.mak Loading commit data...
acodec.mak Loading commit data...
adpcm.mak Loading commit data...
alac.mak Loading commit data...
als.mak Loading commit data...
amrnb.mak Loading commit data...
amrwb.mak Loading commit data...
atrac.mak Loading commit data...
audio.mak Loading commit data...
avformat.mak Loading commit data...
bmp.mak Loading commit data...
canopus.mak Loading commit data...
cdxl.mak Loading commit data...
checkasm.mak Loading commit data...
cover-art.mak Loading commit data...
demux.mak Loading commit data...
dfa.mak Loading commit data...
dpcm.mak Loading commit data...
ea.mak Loading commit data...
fft.mak Loading commit data...
filter-audio.mak Loading commit data...
filter-video.mak Loading commit data...
flac.mak Loading commit data...
h264.mak Loading commit data...
hevc.mak Loading commit data...
image.mak Loading commit data...
indeo.mak Loading commit data...
libavcodec.mak Loading commit data...
libavdevice.mak Loading commit data...
libavformat.mak Loading commit data...
libavresample.mak Loading commit data...
libavutil.mak Loading commit data...
lossless-audio.mak Loading commit data...
lossless-video.mak Loading commit data...
microsoft.mak Loading commit data...
monkeysaudio.mak Loading commit data...
mov.mak Loading commit data...
mp3.mak Loading commit data...
mpc.mak Loading commit data...
mpeg4.mak Loading commit data...
opus.mak Loading commit data...
pcm.mak Loading commit data...
probe.mak Loading commit data...
prores.mak Loading commit data...
qt.mak Loading commit data...
qtrle.mak Loading commit data...
real.mak Loading commit data...
screen.mak Loading commit data...
seek.mak Loading commit data...
utvideo.mak Loading commit data...
vcodec.mak Loading commit data...
video.mak Loading commit data...
voice.mak Loading commit data...
vorbis.mak Loading commit data...
vpx.mak Loading commit data...
vqf.mak Loading commit data...
wavpack.mak Loading commit data...
wma.mak Loading commit data...
xvid.mak Loading commit data...