[vlc-commits] [Git][videolan/vlc][master] vout: fix data-race with decoder_fifo

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Nov 29 05:14:34 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c18888ed by Thomas Guillem at 2025-11-29T04:50:42+00:00
vout: fix data-race with decoder_fifo

Allocate `decoder_fifo` from Create to avoid a data-race between
`vout_IsEmpty()` and `vout_Start()`.

```
WARNING: ThreadSanitizer: data race (pid=1391582)
  Read of size 8 at 0x726000010360 by thread T205:
    #0 vout_IsEmpty ../../src/video_output/video_output.c:286 (libvlccore.so.9+0xba067) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #1 vlc_input_decoder_IsDrainedLocked ../../src/input/decoder.c:2496 (libvlccore.so.9+0x65518) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #2 vlc_input_decoder_IsDrained ../../src/input/decoder.c:2506 (libvlccore.so.9+0x65e79) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #3 EsOutDestroyDecoder ../../src/input/es_out.c:2459 (libvlccore.so.9+0x757af) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #4 EsOutUnselectEs ../../src/input/es_out.c:2581 (libvlccore.so.9+0x75981) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #5 EsOutProgramSelect ../../src/input/es_out.c:1469 (libvlccore.so.9+0x75dd0) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #6 EsOutVaControlLocked ../../src/input/es_out.c:3536 (libvlccore.so.9+0x79556) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #7 EsOutControl ../../src/input/es_out.c:4061 (libvlccore.so.9+0x79f2a) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #8 es_out_in_vaControl ../../src/input/es_out_timeshift.c:457 (libvlccore.so.9+0x7c337) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #9 es_out_in_Control ../../src/input/es_out_timeshift.c:468 (libvlccore.so.9+0x7c337)
    #10 CmdExecuteControl ../../src/input/es_out_timeshift.c:1742 (libvlccore.so.9+0x7c3d7) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #11 ControlLocked ../../src/input/es_out_timeshift.c:668 (libvlccore.so.9+0x7c8bb) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #12 Control ../../src/input/es_out_timeshift.c:740 (libvlccore.so.9+0x7ccee) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #13 es_out_vaControl ../../include/vlc_es_out.h:162 (libvlccore.so.9+0x80614) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #14 es_out_Control ../../include/vlc_es_out.h:171 (libvlccore.so.9+0x80614)
    #15 Control ../../src/input/input.c:2127 (libvlccore.so.9+0x86dac) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #16 MainLoop ../../src/input/input.c:753 (libvlccore.so.9+0x897f6) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #17 Run ../../src/input/input.c:414 (libvlccore.so.9+0x899e3) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)

  Previous write of size 8 at 0x726000010360 by thread T207:
    #0 vout_Start ../../src/video_output/video_output.c:1821 (libvlccore.so.9+0xb97f5) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #1 vout_Request ../../src/video_output/video_output.c:2413 (libvlccore.so.9+0xbc705) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #2 input_resource_RequestVout ../../src/input/resource.c:495 (libvlccore.so.9+0x9f385) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #3 ModuleThread_UpdateVideoFormat ../../src/input/decoder.c:677 (libvlccore.so.9+0x63fb1) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #4 decoder_UpdateVideoOutput ../../src/input/decoder_helpers.c:193 (libvlccore.so.9+0x6808b) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #5 decoder_UpdateVideoFormat ../../src/input/decoder_helpers.c:119 (libvlccore.so.9+0x680cc) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #6 DecodeFrame ../../modules/codec/rawvideo.c:250 (librawvideo_plugin.so+0x1ca2) (BuildId: f2d67b7b24ac9e5127596406c568126f931dc8ca)
    #7 DecoderThread_DecodeBlock ../../src/input/decoder.c:1642 (libvlccore.so.9+0x608af) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #8 DecoderThread_ProcessInput ../../src/input/decoder.c:1768 (libvlccore.so.9+0x60d91) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
    #9 DecoderThread ../../src/input/decoder.c:1882 (libvlccore.so.9+0x61002) (BuildId: 1599d2bb5db736fbd51ed60e006a99dcf851bb82)
```

- - - - -


1 changed file:

- src/video_output/video_output.c


Changes:

=====================================
src/video_output/video_output.c
=====================================
@@ -283,8 +283,7 @@ bool vout_IsEmpty(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
     assert(!sys->dummy);
-    if (!sys->decoder_fifo)
-        return true;
+    assert(sys->decoder_fifo);
 
     return picture_fifo_IsEmpty(sys->decoder_fifo);
 }
@@ -1818,7 +1817,6 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
                                         cfg->mouse_event, cfg->mouse_opaque);
     vlc_mutex_unlock(&sys->window_lock);
 
-    sys->decoder_fifo = picture_fifo_New();
     sys->private_pool = NULL;
 
     sys->filter.configuration = NULL;
@@ -1937,11 +1935,6 @@ error:
         vlc_video_context_Release(sys->filter.src_vctx);
         sys->filter.src_vctx = NULL;
     }
-    if (sys->decoder_fifo != NULL)
-    {
-        picture_fifo_Delete(sys->decoder_fifo);
-        sys->decoder_fifo = NULL;
-    }
     vlc_mutex_lock(&sys->window_lock);
     vout_display_window_SetMouseHandler(sys->display_cfg.window, NULL, NULL);
     vlc_mutex_unlock(&sys->window_lock);
@@ -2028,11 +2021,6 @@ static void vout_ReleaseDisplay(vout_thread_sys_t *vout)
     }
     free(sys->filter.configuration);
 
-    if (sys->decoder_fifo != NULL)
-    {
-        picture_fifo_Delete(sys->decoder_fifo);
-        sys->decoder_fifo = NULL;
-    }
     assert(sys->private_pool == NULL);
 
     vlc_mutex_lock(&sys->window_lock);
@@ -2122,6 +2110,8 @@ void vout_Release(vout_thread_t *vout)
         return;
     }
 
+    picture_fifo_Delete(sys->decoder_fifo);
+
     free(sys->splitter_name);
     free(sys->display_cfg.icc_profile);
 
@@ -2177,6 +2167,13 @@ vout_thread_t *vout_Create(vlc_object_t *object)
     vout_thread_sys_t *sys = p_vout;
     sys->dummy = false;
 
+    sys->decoder_fifo = picture_fifo_New();
+    if (sys->decoder_fifo == NULL)
+    {
+        vlc_object_delete(vout);
+        return NULL;
+    }
+
     /* Register the VLC variable and callbacks. On the one hand, the variables
      * must be ready early on because further initializations below depend on
      * some of them. On the other hand, the callbacks depend on said
@@ -2192,6 +2189,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
     if (config_GetType("video-splitter")) {
         char *splitter_name = var_InheritString(vout, "video-splitter");
         if (unlikely(splitter_name == NULL)) {
+            picture_fifo_Delete(sys->decoder_fifo);
             vlc_object_delete(vout);
             return NULL;
         }
@@ -2245,6 +2243,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
     if (sys->display_cfg.window == NULL) {
         if (sys->spu)
             spu_Destroy(sys->spu);
+        picture_fifo_Delete(sys->decoder_fifo);
         vlc_object_delete(vout);
         return NULL;
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c18888edf0a5214dd1a0b876fb1fbe3bf79431e8

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


VideoLAN code repository instance


More information about the vlc-commits mailing list