The lookahead_thread main loop checks b_exit_thread and exits if it is set.
That flag is set by x264_lookahead_delete, which uses ifbuf.mutex to guard accessing it.
However, the read in the while-loop condition of lookahead_thread is not guarded,
and so TSAN sometimes reports a data race.
REALIGN_STACK static void *lookahead_thread( x264_t *h )
{
- while( !h->lookahead->b_exit_thread )
+ while( 1 )
{
x264_pthread_mutex_lock( &h->lookahead->ifbuf.mutex );
+ if( h->lookahead->b_exit_thread )
+ {
+ x264_pthread_mutex_unlock( &h->lookahead->ifbuf.mutex );
+ break;
+ }
x264_pthread_mutex_lock( &h->lookahead->next.mutex );
int shift = X264_MIN( h->lookahead->next.i_max_size - h->lookahead->next.i_size, h->lookahead->ifbuf.i_size );
lookahead_shift( &h->lookahead->next, &h->lookahead->ifbuf, shift );