[x264-devel] [Git][videolan/x264][master] lookahead: Keep b_exit_thread under ifbuf.mutex

Anton Mitrofanov (@BugMaster) gitlab at videolan.org
Wed Sep 29 21:38:15 UTC 2021



Anton Mitrofanov pushed to branch master at VideoLAN / x264


Commits:
66a5bc1b by Jean-Baptiste Kempf at 2021-09-29T21:34:37+00:00
lookahead: Keep b_exit_thread under ifbuf.mutex

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.

- - - - -


1 changed file:

- encoder/lookahead.c


Changes:

=====================================
encoder/lookahead.c
=====================================
@@ -89,9 +89,14 @@ static void lookahead_slicetype_decide( x264_t *h )
 
 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 );



View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/66a5bc1bd1563d8227d5d18440b525a09bcf17ca

-- 
View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/66a5bc1bd1563d8227d5d18440b525a09bcf17ca
You're receiving this email because of your account on code.videolan.org.




More information about the x264-devel mailing list