From 71eefb977b783a0f896fe76237f35ccbe532b496 Mon Sep 17 00:00:00 2001 From: "Pohsiang (John) Hsu" Date: Wed, 30 Jul 2025 12:43:14 -0700 Subject: [PATCH] mediafoundation: fix deadlock when user call shutdown and endGetEvent concurrently The issue occurs when 'IMFShutdown::Shutdown' is called on MFT on one thread and IMFMediaEventGenerator::EndGetEvent' is called on another thread. Shutdown is taking a lock (m_lockShutdown), changes m_bShutdown to true, then calls OnFlush which takes API lock (m_lock) EndGetEvent and all other API's take an API lock (m_lock), then calls checkshutdownstatus() which takes the m_lockShutdown. So if Shutdown acquires m_lockShutdown and prior to acquiring API lock, and EndGetEvent acquire m_lock, then we have deadlock on m_lockShutdown. Since the CheckShutdownStatus is only checking the m_bShutdown variable, it really doesn't have to be protected by the shutdown lock. Reviewed-by: Jesse Natalie Reviewed-by: Yubo Xie Part-of: --- src/gallium/frontends/mediafoundation/mfshutdown.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/frontends/mediafoundation/mfshutdown.cpp b/src/gallium/frontends/mediafoundation/mfshutdown.cpp index 490b0cdfd06..fe45270317f 100644 --- a/src/gallium/frontends/mediafoundation/mfshutdown.cpp +++ b/src/gallium/frontends/mediafoundation/mfshutdown.cpp @@ -28,7 +28,6 @@ HRESULT CDX12EncHMFT::CheckShutdown( void ) { - std::lock_guard lock( m_lockShutdown ); if( m_bShutdown ) { return MF_E_SHUTDOWN;