Skip to content

Commit

Permalink
input: decoder: fix data race on decoder format
Browse files Browse the repository at this point in the history
We cannot read or write the decoder object without being under the fifo
lock, so ensure we locked first. It fixes some thread sanitizer issues
between decoder_Init() and vlc_input_decoder_Flush().

    WARNING: ThreadSanitizer: data race (pid=876901)
      Read of size 8 at 0x7b7000010028 by thread T25:
        #0 vlc_input_decoder_Flush ../../src/input/decoder.c:2317 (libvlccore.so.9+0x69d7a) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        #1 EsOutDestroyDecoder ../../src/input/es_out.c:2360 (libvlccore.so.9+0x716cf) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#2 EsOutUnselectEs ../../src/input/es_out.c:2534 (libvlccore.so.9+0x7a1bd) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#3 EsOutVaPrivControlLocked ../../src/input/es_out.c:3733 (libvlccore.so.9+0x75832) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#4 EsOutPrivControl ../../src/input/es_out.c:4043 (libvlccore.so.9+0x783ad) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        #5 es_out_in_vaPrivControl ../../src/input/es_out_timeshift.c:464 (libvlccore.so.9+0x81a06) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        #6 es_out_in_PrivControl ../../src/input/es_out_timeshift.c:474 (libvlccore.so.9+0x81a06)
        videolan#7 CmdExecutePrivControl ../../src/input/es_out_timeshift.c:1868 (libvlccore.so.9+0x81b78) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#8 PrivControlLocked ../../src/input/es_out_timeshift.c:758 (libvlccore.so.9+0x840be) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#9 PrivControl ../../src/input/es_out_timeshift.c:817 (libvlccore.so.9+0x840be)
        videolan#10 es_out_vaPrivControl ../../src/input/es_out.h:105 (libvlccore.so.9+0x86f7c) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#11 es_out_PrivControl ../../src/input/es_out.h:112 (libvlccore.so.9+0x86f7c)
        videolan#12 es_out_SetMode ../../src/input/es_out.h:119 (libvlccore.so.9+0x91ba9) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#13 End ../../src/input/input.c:1425 (libvlccore.so.9+0x91ba9)
        videolan#14 Run ../../src/input/input.c:431 (libvlccore.so.9+0x920d4) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)

      Previous write of size 8 at 0x7b7000010028 by thread T27:
        #0 decoder_Init ../../src/input/decoder_helpers.c:50 (libvlccore.so.9+0x6c1ce) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        #1 LoadDecoder ../../src/input/decoder.c:370 (libvlccore.so.9+0x672ae) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#2 DecoderThread_Reload ../../src/input/decoder.c:431 (libvlccore.so.9+0x67593) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#3 DecoderThread_ProcessInput ../../src/input/decoder.c:1595 (libvlccore.so.9+0x687f9) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        videolan#4 DecoderThread_DecodeBlock ../../src/input/decoder.c:1562 (libvlccore.so.9+0x6865b) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        #5 DecoderThread_ProcessInput ../../src/input/decoder.c:1667 (libvlccore.so.9+0x6895e) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
        #6 DecoderThread ../../src/input/decoder.c:1795 (libvlccore.so.9+0x6a487) (BuildId: 1912c3713753e3bafbd8f9b735ec069a39be1f4d)
  • Loading branch information
alexandre-janniaux authored and jbkempf committed Aug 15, 2023
1 parent 8daa3f6 commit f19e27a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/input/decoder.c
Expand Up @@ -2313,9 +2313,8 @@ void vlc_input_decoder_Drain( vlc_input_decoder_t *p_owner )

void vlc_input_decoder_Flush( vlc_input_decoder_t *p_owner )
{
enum es_format_category_e cat = p_owner->dec.fmt_in->i_cat;

vlc_fifo_Lock( p_owner->p_fifo );
enum es_format_category_e cat = p_owner->dec.fmt_in->i_cat;

/* Empty the fifo */
block_ChainRelease( vlc_fifo_DequeueAllUnlocked( p_owner->p_fifo ) );
Expand Down

0 comments on commit f19e27a

Please sign in to comment.