[Mesa-dev] [PATCH] Don't set swap interval for PBuffer surface. This fixes crash due to NULL window.

Erik Faye-Lund kusmabite at gmail.com
Sat Apr 28 07:20:00 UTC 2018


On Fri, Apr 27, 2018 at 11:17 AM, samiuddi
<sami.uddin.mohammad at intel.com> wrote:
> Test: CtsDisplayTestCases pass
>
> Signed-off-by: samiuddi <sami.uddin.mohammad at intel.com>
> ---
>  src/egl/drivers/dri2/platform_android.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index 976dd10..5048830 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -480,6 +480,9 @@ static EGLBoolean
>  droid_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy,
>                     _EGLSurface *surf, EGLint interval)
>  {
> +   if (surf->Type == EGL_PBUFFER_BIT)
> +      return EGL_FALSE;
> +
>     struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
>     struct ANativeWindow *window = dri2_surf->window;
>

While it seems like pbuffers are the only non-window surface-type the
android-driver supports, would it not be cleaner to check for
EGL_WINDOW_BIT here instead?

Also, I don't think EGL_FALSE is the right return-value, as it doesn't
seem the EGL 1.5 spec defines any such error. Also, for instance
dri2_swap_interval returns EGL_TRUE when there's no driver-function,
which further backs the "silent failure" in this case IMO.

But, can't we check if the window is non-NULL on usage instead?
Something like this...

diff --git a/src/egl/drivers/dri2/platform_android.c
b/src/egl/drivers/dri2/platform_android.c
index 7f1a496ea24..41bdcc2f175 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -424,7 +424,7 @@ droid_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy,
    struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
    struct ANativeWindow *window = dri2_surf->window;

-   if (window->setSwapInterval(window, interval))
+   if (window && window->setSwapInterval(window, interval))
       return EGL_FALSE;

    surf->SwapInterval = interval;


More information about the mesa-dev mailing list