From 46131f0cb022202fd4411aebdb8aa26c85ca93c3 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 27 Apr 2024 22:54:14 +0900 Subject: [PATCH] d3d12ipcclient: Fix deadlock when copying texture Fixing deadlock in below case * GC lock is taken by background thread, and the background thread calls gst_d3d12_ipc_client_release_imported_data() which takes ipc lock * ipc lock is already taken in ipc thread and trying to pushing GC data via gst_d3d12_command_queue_set_notify() * gst_d3d12_command_queue_set_notify() is trying to take GC lock but it's already taken by background thread Part-of: --- subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcclient.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcclient.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcclient.cpp index d5efe97cf5..34010abc84 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcclient.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcclient.cpp @@ -511,6 +511,8 @@ gst_d3d12_ipc_client_have_data (GstD3D12IpcClient * self) fence_val); } + lk.unlock (); + guint64 copy_fence_val; gst_d3d12_device_copy_texture_region (priv->device, copy_args.size (), copy_args.data (), nullptr, nullptr, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, @@ -524,6 +526,8 @@ gst_d3d12_ipc_client_have_data (GstD3D12IpcClient * self) (GDestroyNotify) gst_d3d12_ipc_client_release_imported_data); gst_d3d12_buffer_after_write (buffer, copy_fence_val); + + lk.lock (); } else { gint stride[GST_VIDEO_MAX_PLANES]; gsize offset[GST_VIDEO_MAX_PLANES];