Skip to content

Commit

Permalink
avcodec/h264_slice: don't sync default_ref[] between threads.
Browse files Browse the repository at this point in the history
default_ref[] is unconditionally initialized in h264_initialise_ref_list()
(called from ff_h264_build_ref_list(), called from h264_slice_init()).

This fixes the following tsan warning when running fate-h264:

WARNING: ThreadSanitizer: data race (pid=31070)
  Write of size 8 at 0x7bbc000082a8 by thread T1 (mutexes: write M1628):
    #0 memcpy /work/release-test/final/llvm.src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:655:5
(ffmpeg+0x10de9d)
    bilibili#1 h264_initialise_ref_list ffmpeg/libavcodec/h264_refs.c:214:29 (ffmpeg+0x1186b3f)
    bilibili#2 ff_h264_build_ref_list ffmpeg/libavcodec/h264_refs.c:306 (ffmpeg+0x1186b3f)
    bilibili#3 h264_slice_init ffmpeg/libavcodec/h264_slice.c:1900:11 (ffmpeg+0x1191149)
[..]
  Previous read of size 8 at 0x7bbc000082a8 by main thread (mutexes:
write M1630):
    #0 memcpy /work/release-test/final/llvm.src/projects/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:655:5
(ffmpeg+0x10de9d)
    bilibili#1 ff_h264_update_thread_context ffmpeg/libavcodec/h264_slice.c:411:5 (ffmpeg+0x118b7dc)

Signed-off-by: Wan-Teh Chang <[email protected]>
Signed-off-by: Ronald S. Bultje <[email protected]>
  • Loading branch information
Wan-Teh Chang authored and rbultje committed Jul 27, 2017
1 parent 9f44922 commit 8c3b329
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion libavcodec/h264_slice.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ int ff_h264_update_thread_context(AVCodecContext *dst,

memcpy(&h->poc, &h1->poc, sizeof(h->poc));

memcpy(h->default_ref, h1->default_ref, sizeof(h->default_ref));
memcpy(h->short_ref, h1->short_ref, sizeof(h->short_ref));
memcpy(h->long_ref, h1->long_ref, sizeof(h->long_ref));
memcpy(h->delayed_pic, h1->delayed_pic, sizeof(h->delayed_pic));
Expand Down

0 comments on commit 8c3b329

Please sign in to comment.