[vlc-devel] [PATCH 1/2] lua: Fix deadlock when deactivating extension due to timeout.

Rémi Denis-Courmont remi at remlab.net
Mon Mar 27 18:23:43 CEST 2017


Le maanantaina 27. maaliskuuta 2017, 17.03.33 EEST Hugo Beauzée-Luyssen a 
écrit :
> lua_ExecuteFunctionVa is not meant to be called with the command_lock
> held.
> This partially reverts 7a94f2e6b22bad255ddcca6e095ed33bc4803e45
> Fix #17565
> ---
>  modules/lua/extension.c        | 6 +++---
>  modules/lua/extension_thread.c | 4 +++-
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/modules/lua/extension.c b/modules/lua/extension.c
> index 92c2eb7fa7..32009cc0ba 100644
> --- a/modules/lua/extension.c
> +++ b/modules/lua/extension.c
> @@ -1223,8 +1223,8 @@ static void WatchTimerCallback( void *data )
>                  vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
>                  p_ext->p_sys->p_progress_id = NULL;
>              }
> -            KillExtension( p_mgr, p_ext );
>              vlc_mutex_unlock( &p_ext->p_sys->command_lock );
> +            KillExtension( p_mgr, p_ext );

lua_ExtensionDeactivate() can not to be called without the lock, AFAICT. And 
KillExtension() calls it.

>              return;
>          }
> 
> @@ -1239,8 +1239,8 @@ static void WatchTimerCallback( void *data )
>                                           p_ext->psz_title );
>          if( p_ext->p_sys->p_progress_id == NULL )
>          {
> -            KillExtension( p_mgr, p_ext );
>              vlc_mutex_unlock( &p_ext->p_sys->command_lock );
> +            KillExtension( p_mgr, p_ext );
>              return;
>          }
>          vlc_timer_schedule( p_ext->p_sys->timer, false, 100000, 0 );
> @@ -1251,8 +1251,8 @@ static void WatchTimerCallback( void *data )
>          {
>              vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
>              p_ext->p_sys->p_progress_id = NULL;
> -            KillExtension( p_mgr, p_ext );
>              vlc_mutex_unlock( &p_ext->p_sys->command_lock );
> +            KillExtension( p_mgr, p_ext );
>              return;
>          }
>          vlc_timer_schedule( p_ext->p_sys->timer, false, 100000, 0 );
> diff --git a/modules/lua/extension_thread.c b/modules/lua/extension_thread.c
> index affa65912b..6cf3ca6e92 100644
> --- a/modules/lua/extension_thread.c
> +++ b/modules/lua/extension_thread.c
> @@ -153,8 +153,8 @@ int Deactivate( extensions_manager_t *p_mgr, extension_t
> *p_ext ) // Extension is stuck, kill it now
>          vlc_dialog_release( p_mgr, p_ext->p_sys->p_progress_id );
>          p_ext->p_sys->p_progress_id = NULL;
> -        KillExtension( p_mgr, p_ext );
>          vlc_mutex_unlock( &p_ext->p_sys->command_lock );
> +        KillExtension( p_mgr, p_ext );
>          return VLC_SUCCESS;
>      }
> 
> @@ -217,8 +217,10 @@ void KillExtension( extensions_manager_t *p_mgr,
> extension_t *p_ext ) {
>      msg_Dbg( p_mgr, "Killing extension now" );
>      lua_ExtensionDeactivate( p_mgr, p_ext );
> +    vlc_mutex_lock( &p_ext->p_sys->command_lock );
>      p_ext->p_sys->b_exiting = true;
>      vlc_cond_signal( &p_ext->p_sys->wait );
> +    vlc_mutex_unlock( &p_ext->p_sys->command_lock );
>      RemoveActivated( p_mgr, p_ext );
>  }


-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list