GNOME Bugzilla – Bug 768154
d3dvideosink: start/stop concurrency between multiple sinks
Last modified: 2018-11-03 13:52:45 UTC
Created attachment 330505 [details] [review] 0004-d3dvideosink-start-stop-lock.patch Concurrent start/stop actions on multiple d3dvideosink instances running in parallel (distinct pipelines) may cause a crash. There is already a class mutex that is properly used in d3d_class_init and d3d_class_destroy, but it is momentarily released in both functions to let the window proc thread proceed. This opens up a breach for simultaneous start and/or stop calls to conflict, even on distinct sink instances. Attached patch introduces another class mutex to serialize concurrent starts and stops.
Question is why the mutex is shortly released in both functions, and if you don't introduce the problem this was meant to prevent again by having another mutex around everything.
We need something to protect access to klass->d3d.thread, which klass->lock obviously cannot fulfil, because the thread in question (the window proc thread) itself locks klass->lock through d3d_class_ calls. That is why the lock has to be released momentarily when _start or _stop instantiate or terminate the thread (and intently waiting for that to happen). As far as I can tell, the window proc thread never calls _start or _stop. Those methods are called on element state changes triggered outside of the element. Therefore, nothing will block on klass->start_stop_lock other than the _start and _stop calls, thereby achieving the serialization effect we are looking for. We stumbled on this issue through robustness testing (start/stop cycles every few seconds running for several hours). Doesn't occur that often, and it is quite possible it would never happen while running only a single sink at a time.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/404.