From c317a3ee89e79b6c26ad5c4406e56998723f2f92 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Wed, 17 Apr 2024 15:58:10 +0200 Subject: [PATCH] Merge pull request #25419 from vrabaud:ffmpeg Fix race condition in InternalFFMpegRegister initialization. #25419 initLogger_ does not check if the logger has been initizalized before and it might initialize it several times from different threads, racing with other threads that are logging. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work --- modules/videoio/src/cap_ffmpeg_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp index 9be4b082793c..0546fbdfbedc 100644 --- a/modules/videoio/src/cap_ffmpeg_impl.hpp +++ b/modules/videoio/src/cap_ffmpeg_impl.hpp @@ -927,7 +927,6 @@ class InternalFFMpegRegister if(!threadSafe) lock.lock(); static InternalFFMpegRegister instance; - initLogger_(); // update logger setup unconditionally (GStreamer's libav plugin may override these settings) } static void initLogger_() { @@ -965,6 +964,7 @@ class InternalFFMpegRegister /* register a callback function for synchronization */ av_lockmgr_register(&LockCallBack); #endif + initLogger_(); } ~InternalFFMpegRegister() {