Data race in common/deblock.c and encoder/encoder.c
Hello,
I'm developing a new dynamic race detection tool on top of ThreadSanitizer, which found a new data race in the X264 project. Please find the detailed report below.
==================
WARNING: ThreadSanitizer: data race (pid=415690)
Bug-message: current shadow: {tid=4@3 access=0xf0 typ=0} old shadow: {tid=0@25 access=0xff typ=1}
Write of size 4 at 0x7bc400042024 by thread T4:
#0 macroblock_cache_load_neighbours_deblock ~/x264/common/deblock.c:346:24 (x264+0x1db4b2)
#1 x264_8_frame_deblock_row ~/x264/common/deblock.c:394:9 (x264+0x1db4b2)
#2 fdec_filter_row ~/x264/encoder/encoder.c:2458:13 (x264+0x14c3a9)
#3 slice_write ~/x264/encoder/encoder.c:2824:17 (x264+0x14508a)
#4 slices_write ~/x264/encoder/encoder.c:3202:13 (x264+0x14508a)
#5 threadpool_thread ~/x264/common/threadpool.c:64:20 (x264+0x14e28c)
Previous read of size 8 at 0x7bc400042020 by main thread:
#0 __tsan_memcpy ~/tsan/rtl/tsan_interceptors_posix.cpp:3165:3 (x264+0xa2799)
#1 thread_sync_context ~/x264/encoder/encoder.c:3146:5 (x264+0x13769d)
#2 x264_8_encoder_encode ~/x264/encoder/encoder.c:3343:9 (x264+0x13769d)
#3 x264_encoder_encode ~/x264/encoder/api.c:170:12 (x264+0x124e55)
#4 encode_frame ~/x264/x264.c:1858:20 (x264+0x101536)
#5 encode ~/x264/x264.c:2049:24 (x264+0x101536)
#6 main ~/x264/x264.c:392:15 (x264+0x101536)
Location is heap block of size 74304 at 0x7bc40003c000 allocated by main thread:
#0 memalign ~/tsan/rtl/tsan_interceptors_posix.cpp:836:3 (x264+0x7327e)
#1 x264_malloc ~/x264/common/base.c:129:21 (x264+0x11d0cc)
#2 x264_8_encoder_open ~/x264/encoder/encoder.c:1758:9 (x264+0x1315c4)
#3 x264_encoder_open_164 ~/x264/encoder/api.c:96:21 (x264+0x124b1a)
#4 encode ~/x264/x264.c:1957:9 (x264+0x10072b)
#5 main ~/x264/x264.c:392:15 (x264+0x10072b)
Thread T4 (tid=415733, running) created by main thread at:
#0 pthread_create ~/tsan/rtl/tsan_interceptors_posix.cpp:1048:3 (x264+0x61093)
#1 x264_8_threadpool_init ~/x264/common/threadpool.c:98:13 (x264+0x14e11f)
#2 x264_8_encoder_open ~/x264/encoder/encoder.c:1738:9 (x264+0x1314d9)
#3 x264_encoder_open_164 ~/x264/encoder/api.c:96:21 (x264+0x124b1a)
#4 encode ~/x264/x264.c:1957:9 (x264+0x10072b)
#5 main ~/x264/x264.c:392:15 (x264+0x10072b)
SUMMARY: ThreadSanitizer: data race ~/x264/common/deblock.c:346:24 in macroblock_cache_load_neighbours_deblock
==================