Skip to content

Commit

Permalink
Merge pull request opencv#25419 from vrabaud:ffmpeg
Browse files Browse the repository at this point in the history
Fix race condition in InternalFFMpegRegister initialization. opencv#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
  • Loading branch information
vrabaud authored Apr 17, 2024
1 parent 05a54b1 commit c317a3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/videoio/src/cap_ffmpeg_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_()
{
Expand Down Expand Up @@ -965,6 +964,7 @@ class InternalFFMpegRegister
/* register a callback function for synchronization */
av_lockmgr_register(&LockCallBack);
#endif
initLogger_();
}
~InternalFFMpegRegister()
{
Expand Down

0 comments on commit c317a3e

Please sign in to comment.