[vlc-commits] [Git][videolan/vlc][master] avcodec: remove useless flush

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Jun 24 08:51:56 UTC 2022



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
1cd6abdf by Alexandre Janniaux at 2022-06-24T08:38:07+00:00
avcodec: remove useless flush

There is no requirement to call flush on exit. Indeed,
avcodec_flush_buffers is documented as needed for seeking or switching
to a different stream.

In addition, calling avcodec_flush_buffers currently triggers TSAN
warnings. Those warnings are still happening when calling the pf_flush
function from avcodec module, so it does not fix them per se, but it
does remove a systematic TSAN warning when opening/closing avcodec.

With ffmpeg at commit 73302aa193714958afb8262ceb14d9613e9df5ad:

    WARNING: ThreadSanitizer: data race (pid=749126)
      Write of size 8 at 0x7b8000053000 by thread T9:
        #0 free /usr/src/debug/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:706 (libtsan.so.2+0x4e64f)
        #1 ff_h264_free_tables src/libavcodec/h264dec.c:159 (libavcodec_plugin.so+0x24bced)
        #2 module_unneed ../../src/modules/modules.c:304 (libvlccore.so.9+0x4ce1a)
        #3 decoder_Clean ../../src/input/decoder_helpers.c:56 (libvlccore.so.9+0x8835f)
        #4 DeleteDecoder ../../src/input/decoder.c:2005 (libvlccore.so.9+0x83edd)
        #5 vlc_input_decoder_Delete ../../src/input/decoder.c:2254 (libvlccore.so.9+0x84f5c)
        #6 EsOutDestroyDecoder ../../src/input/es_out.c:2406 (libvlccore.so.9+0x97c9b)
        #7 EsOutUnselectEs ../../src/input/es_out.c:2575 (libvlccore.so.9+0x98902)
        #8 EsOutVaPrivControlLocked ../../src/input/es_out.c:3734 (libvlccore.so.9+0x9f359)
        #9 EsOutPrivControl ../../src/input/es_out.c:4028 (libvlccore.so.9+0xa1f0a)
        #10 es_out_vaPrivControl ../../src/input/es_out.h:105 (libvlccore.so.9+0xa554f)
        #11 es_out_PrivControl ../../src/input/es_out.h:112 (libvlccore.so.9+0xa5623)
        #12 CmdExecutePrivControl ../../src/input/es_out_timeshift.c:1809 (libvlccore.so.9+0xadb9f)
        #13 PrivControlLocked ../../src/input/es_out_timeshift.c:799 (libvlccore.so.9+0xa7c59)
        #14 PrivControl ../../src/input/es_out_timeshift.c:858 (libvlccore.so.9+0xa8428)
        #15 es_out_vaPrivControl ../../src/input/es_out.h:105 (libvlccore.so.9+0xafd79)
        #16 es_out_PrivControl ../../src/input/es_out.h:112 (libvlccore.so.9+0xafe4d)
        #17 es_out_SetMode ../../src/input/es_out.h:119 (libvlccore.so.9+0xafeb1)
        #18 End ../../src/input/input.c:1400 (libvlccore.so.9+0xb5ec5)
        #19 Run ../../src/input/input.c:431 (libvlccore.so.9+0xb1ba0)

      Previous write of size 8 at 0x7b8000053000 by thread T10 (mutexes: write M847):
        #0 memset /usr/src/debug/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:799 (libtsan.so.2+0x652d2)
        #1 ff_er_add_slice src/libavcodec/error_resilience.c:863 (libavcodec_plugin.so+0x866185)

      Mutex M847 (0x7b7400024ea8) created at:
        #0 pthread_mutex_init /usr/src/debug/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:1295 (libtsan.so.2+0x57446)
        #1 ff_pthread_init src/libavcodec/pthread.c:122 (libavcodec_plugin.so+0x93ce3)
        #2 OpenVideoCodec ../../modules/codec/avcodec/video.c:393 (libavcodec_plugin.so+0xdaac8)
        #3 InitVideoDec ../../modules/codec/avcodec/video.c:592 (libavcodec_plugin.so+0xdbb26)
        #4 generic_start ../../src/modules/modules.c:275 (libvlccore.so.9+0x4cc3d)
        #5 vlc_module_load ../../src/modules/modules.c:243 (libvlccore.so.9+0x4c9db)
        #6 module_need ../../src/modules/modules.c:286 (libvlccore.so.9+0x4cce2)
        #7 module_need_var ../../include/vlc_modules.h:120 (libvlccore.so.9+0x7b8cb)
        #8 LoadDecoder ../../src/input/decoder.c:234 (libvlccore.so.9+0x7bea7)
        #9 CreateDecoder ../../src/input/decoder.c:1958 (libvlccore.so.9+0x83a70)
        #10 decoder_New ../../src/input/decoder.c:2111 (libvlccore.so.9+0x847ba)
        #11 vlc_input_decoder_New ../../src/input/decoder.c:2172 (libvlccore.so.9+0x84be5)
        #12 EsOutCreateDecoder ../../src/input/es_out.c:2358 (libvlccore.so.9+0x977d5)
        #13 EsOutSelectEs ../../src/input/es_out.c:2488 (libvlccore.so.9+0x98261)
        #14 EsOutSelect ../../src/input/es_out.c:2774 (libvlccore.so.9+0x992d1)
        #15 EsOutVaPrivControlLocked ../../src/input/es_out.c:3738 (libvlccore.so.9+0x9f418)
        #16 EsOutPrivControl ../../src/input/es_out.c:4028 (libvlccore.so.9+0xa1f0a)
        #17 es_out_vaPrivControl ../../src/input/es_out.h:105 (libvlccore.so.9+0xa554f)
        #18 es_out_PrivControl ../../src/input/es_out.h:112 (libvlccore.so.9+0xa5623)
        #19 CmdExecutePrivControl ../../src/input/es_out_timeshift.c:1809 (libvlccore.so.9+0xadb9f)
        #20 PrivControlLocked ../../src/input/es_out_timeshift.c:799 (libvlccore.so.9+0xa7c59)
        #21 PrivControl ../../src/input/es_out_timeshift.c:858 (libvlccore.so.9+0xa8428)
        #22 es_out_vaPrivControl ../../src/input/es_out.h:105 (libvlccore.so.9+0xafd79)
        #23 es_out_PrivControl ../../src/input/es_out.h:112 (libvlccore.so.9+0xafe4d)
        #24 es_out_SetMode ../../src/input/es_out.h:119 (libvlccore.so.9+0xafeb1)
        #25 InitPrograms ../../src/input/input.c:1227 (libvlccore.so.9+0xb5322)
        #26 Init ../../src/input/input.c:1316 (libvlccore.so.9+0xb58c9)
        #27 Run ../../src/input/input.c:426 (libvlccore.so.9+0xb1b7f)

      Thread T9 'vlc-input' (tid=749136, running) created by main thread at:
        #0 pthread_create /usr/src/debug/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:1001 (libtsan.so.2+0x670c9)
        #1 vlc_clone_attr ../../src/posix/thread.c:179 (libvlccore.so.9+0x17910c)
        #2 vlc_clone ../../src/posix/thread.c:190 (libvlccore.so.9+0x1791b5)
        #3 input_Start ../../src/input/input.c:130 (libvlccore.so.9+0xb0aca)
        #4 vlc_player_input_Start ../../src/player/input.c:96 (libvlccore.so.9+0xc9640)
        #5 vlc_player_Start ../../src/player/player.c:1176 (libvlccore.so.9+0xc54be)
        #6 vlc_playlist_Start ../../src/playlist/player.c:176 (libvlccore.so.9+0x6146e)
        #7 libvlc_InternalPlay ../../src/interface/interface.c:238 (libvlccore.so.9+0x59fa4)
        #8 libvlc_playlist_play ../../lib/playlist.c:36 (libvlc.so.12+0xdd1b)
        #9 main ../../bin/vlc.c:245 (vlc-static+0x2acd)

      Thread T10 (tid=749137, running) created by thread T9 at:
        #0 pthread_create /usr/src/debug/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp:1001 (libtsan.so.2+0x670c9)
        #1 init_thread src/libavcodec/pthread_frame.c:834 (libavcodec_plugin.so+0x93ebd)
        #2 ff_frame_thread_init src/libavcodec/pthread_frame.c:890 (libavcodec_plugin.so+0x93ebd)
        #3 OpenVideoCodec ../../modules/codec/avcodec/video.c:393 (libavcodec_plugin.so+0xdaac8)
        #4 InitVideoDec ../../modules/codec/avcodec/video.c:592 (libavcodec_plugin.so+0xdbb26)
        #5 generic_start ../../src/modules/modules.c:275 (libvlccore.so.9+0x4cc3d)
        #6 vlc_module_load ../../src/modules/modules.c:243 (libvlccore.so.9+0x4c9db)
        #7 module_need ../../src/modules/modules.c:286 (libvlccore.so.9+0x4cce2)
        #8 module_need_var ../../include/vlc_modules.h:120 (libvlccore.so.9+0x7b8cb)
        #9 LoadDecoder ../../src/input/decoder.c:234 (libvlccore.so.9+0x7bea7)
        #10 CreateDecoder ../../src/input/decoder.c:1958 (libvlccore.so.9+0x83a70)
        #11 decoder_New ../../src/input/decoder.c:2111 (libvlccore.so.9+0x847ba)
        #12 vlc_input_decoder_New ../../src/input/decoder.c:2172 (libvlccore.so.9+0x84be5)
        #13 EsOutCreateDecoder ../../src/input/es_out.c:2358 (libvlccore.so.9+0x977d5)
        #14 EsOutSelectEs ../../src/input/es_out.c:2488 (libvlccore.so.9+0x98261)
        #15 EsOutSelect ../../src/input/es_out.c:2774 (libvlccore.so.9+0x992d1)
        #16 EsOutVaPrivControlLocked ../../src/input/es_out.c:3738 (libvlccore.so.9+0x9f418)
        #17 EsOutPrivControl ../../src/input/es_out.c:4028 (libvlccore.so.9+0xa1f0a)
        #18 es_out_vaPrivControl ../../src/input/es_out.h:105 (libvlccore.so.9+0xa554f)
        #19 es_out_PrivControl ../../src/input/es_out.h:112 (libvlccore.so.9+0xa5623)
        #20 CmdExecutePrivControl ../../src/input/es_out_timeshift.c:1809 (libvlccore.so.9+0xadb9f)
        #21 PrivControlLocked ../../src/input/es_out_timeshift.c:799 (libvlccore.so.9+0xa7c59)
        #22 PrivControl ../../src/input/es_out_timeshift.c:858 (libvlccore.so.9+0xa8428)
        #23 es_out_vaPrivControl ../../src/input/es_out.h:105 (libvlccore.so.9+0xafd79)
        #24 es_out_PrivControl ../../src/input/es_out.h:112 (libvlccore.so.9+0xafe4d)
        #25 es_out_SetMode ../../src/input/es_out.h:119 (libvlccore.so.9+0xafeb1)
        #26 InitPrograms ../../src/input/input.c:1227 (libvlccore.so.9+0xb5322)
        #27 Init ../../src/input/input.c:1316 (libvlccore.so.9+0xb58c9)
        #28 Run ../../src/input/input.c:426 (libvlccore.so.9+0xb1b7f)

SUMMARY: ThreadSanitizer: data race src/libavcodec/h264dec.c:159 in ff_h264_free_tables

Revert of commit f2f61bf1c7c58e79dcb22cada3eea53f596355cc.

- - - - -


1 changed file:

- modules/codec/avcodec/video.c


Changes:

=====================================
modules/codec/avcodec/video.c
=====================================
@@ -1335,12 +1335,7 @@ void EndVideoDec( vlc_object_t *obj )
     decoder_sys_t *p_sys = p_dec->p_sys;
     AVCodecContext *ctx = p_sys->p_context;
 
-    /* do not flush buffers if codec hasn't been opened (theora/vorbis/VC1) */
-    if( avcodec_is_open( ctx ) )
-        avcodec_flush_buffers( ctx );
-
     cc_Flush( &p_sys->cc );
-
     avcodec_free_context( &ctx );
 
     if( p_sys->p_va )



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1cd6abdf6c7db2bd8a8b50c757731d407dcb99ee
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