[Mesa-dev] [PATCH] egl/wayland-egl: Fix for segfault in dri2_wl_destroy_surface.

Stencel, Joanna joanna.stencel at intel.com
Wed Aug 24 07:48:10 UTC 2016


I couldn't find any clear requirement about order of destroys in EGL (or wayland) specification. 
Also, in EGL spec (3.7.3, about eglMakeCurrent) one can find:

" If a native window underlying either draw or read is no longer valid, an
EGL_BAD_NATIVE_WINDOW error is generated."
"If a native window or pixmap underlying the draw or read surfaces is
destroyed, rendering and readback are handled as above."

So it seems that in general destroying native window underlying existing surface can be a case
and should be handled. 
I agree that it's reasonable to call eglDestroySurface() first and probably most people do this.
However, I think that different user's usage shouldn't cause a crash (or memory issues).

Could you explain what you call a memory leak here? Pointer which is nullified points to already
free'd structure of wayland window. 

Joanna 

-----Original Message-----
From: Emil Velikov [mailto:emil.l.velikov at gmail.com] 
Sent: Tuesday, August 23, 2016 6:42 PM
To: Stencel, Joanna <joanna.stencel at intel.com>
Cc: ML mesa-dev <mesa-dev at lists.freedesktop.org>
Subject: Re: [Mesa-dev] [PATCH] egl/wayland-egl: Fix for segfault in dri2_wl_destroy_surface.

On 22 August 2016 at 08:48, Stencel, Joanna <joanna.stencel at intel.com> wrote:
> Segfault occurs when destroying EGL surface attached to already 
> destroyed Wayland window. The fix is to set to NULL the pointer of 
> surface's native window when wl_egl_destroy_window() is called.
>
Are you sure one is not supposed to call eglDestroySurface() first and then wl_egl_window_destroy() ? As-is the patch "fixes" a crash (by creating a leak) caused by user misuse. Should we a) leave the crash to teach people about bugs in their code, b) plug the crash yet cause a leak, or c) plus the crash w/o causing a leak.

I'm leaning towards a) or c) since b) only papers over things.
-Emil
--------------------------------------------------------------------

Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek
przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by
others is strictly prohibited.


More information about the mesa-dev mailing list