[vlc-devel] [PATCH] win32/drawable: fix deadlock

Rémi Denis-Courmont remi at remlab.net
Fri Feb 19 15:11:41 UTC 2021


Le perjantaina 19. helmikuuta 2021, 15.41.31 EET Thomas Guillem a écrit :
> This problem occurs now (and not in VLC 3.0) since Windows mutexes are
> not recursives anymore, cf. 72acfccd5311e8f051843bbd947fd321c7916766.

Dubious. Just because the mutex code would not detect the error does not mean 
the error was not there. I would expect that this leads to a lock inversion 
and/or some weird reentrancy bug.

> ---
>  modules/video_output/win32/drawable.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/modules/video_output/win32/drawable.c
> b/modules/video_output/win32/drawable.c index 90106558848..167edcdae5a
> 100644
> --- a/modules/video_output/win32/drawable.c
> +++ b/modules/video_output/win32/drawable.c
> @@ -74,6 +74,12 @@ struct drawable_sys
>      vlc_sem_t hwnd_set;
> 
>      vout_window_t *wnd;
> +
> +    /* Prevent calling vout_window_Report*() callbacks from an event
> already +     * triggered by a previous vout_window_Report*() call from the
> same thread. +     * */
> +    bool reporting_window;
> +
>      HWND hWnd;
>      HWND embed_hwnd;
>      RECT rect_parent;
> @@ -121,7 +127,12 @@ static LRESULT CALLBACK WinVoutEventProc(HWND hwnd,
> UINT message, break;
> 
>      case WM_CLOSE:
> -        vout_window_ReportClose(wnd);
> +        if (!sys->reporting_window)
> +        {
> +            sys->reporting_window = true;
> +            vout_window_ReportClose(wnd);
> +            sys->reporting_window = false;
> +        }
>          return 0;
> 
>      /* the window has been closed so shut down everything now */
> @@ -131,7 +142,12 @@ static LRESULT CALLBACK WinVoutEventProc(HWND hwnd,
> UINT message, return 0;
> 
>      case WM_SIZE:
> -        vout_window_ReportSize(wnd, LOWORD(lParam), HIWORD(lParam));
> +        if (!sys->reporting_window)
> +        {
> +            sys->reporting_window = true;
> +            vout_window_ReportSize(wnd, LOWORD(lParam), HIWORD(lParam));
> +            sys->reporting_window = false;
> +        }
>          return 0;
> 
>      default:


-- 
レミ・デニ-クールモン
http://www.remlab.net/





More information about the vlc-devel mailing list