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

Thomas Guillem thomas at gllm.fr
Fri Feb 19 16:21:27 UTC 2021



On Fri, Feb 19, 2021, at 16:11, Rémi Denis-Courmont wrote:
> 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.

There was a problem, but it was invisible due to the lock recursivity.
It was not a criticism of your commit. On the contrary, this commit allowed to show an issue via asserts in misc/threads.c

> 
> > ---
> >  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/
> 
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list