[x264-devel] Possible data race bug

Jason Garrett-Glaser jason at x264.com
Fri Feb 1 23:28:51 CET 2013


On Mon, Jan 7, 2013 at 9:05 AM, Paul Thomson <pault543 at gmail.com> wrote:
> Hi,
>
> I am working with an old version of x264. I am benchmarking techniques
> for automatically finding bugs in multithreaded programs. I have come
> across a data race which may be a bug. The sequence of events is as
> follows. There are two threads. I have used 912 and 720 for the
> addresses of the two x264_t structures.
>
> x264_encoder_encode(h=720)
> x264_thread_sync_context(dest=912, source=720)
> create_thread(..., h=912)
> x264_encoder_frame_end(h=720, current=912, ...)
> x264_encoder_encode(h=720)
> x264_thread_sync_context(dest=720, source=912)
>
> At this point, the second thread executes:
> x264_slice_write(h=912)
>
> x264_thread_sync_context reads from source->stat.frame while
> x264_slice_write writes to h->stat.frame (to all 0s). This is a
> read-write data race.
>
> Is this a bug?
>
> It looks like this can still happen in the latest version. Is this the case?

Sorry for the delayed reply.  I don't think this is an issue; the
syncing of the context isn't used to handle stats
(x264_thread_sync_stat is, I think?).  So the data being copied there
isn't actually used.

Jason


More information about the x264-devel mailing list