[Mesa-dev] [Mesa-stable] [PATCH v2] glx: Properly handle cases where screen creation fails
Emil Velikov
emil.l.velikov at gmail.com
Thu Feb 22 15:06:41 UTC 2018
On 22 February 2018 at 14:33, Chuck Atkins <chuck.atkins at kitware.com> wrote:
> This fixes a segfault exposed by a29d63ecf7 which occurs when swr is
> used on an unsupported architecture.
>
> v2: re-work to place logic in xmesa_init_display
>
> Signed-off-by: Chuck Atkins <chuck.atkins at kitware.com>
> Cc: mesa-stable at lists.freedesktop.org
> Cc: George Kyriazis <george.kyriazis at intel.com>
> Cc: Bruce Cherniak <bruce.cherniak at intel.com>
FWIW
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
> src/gallium/state_trackers/glx/xlib/glx_api.c | 5 ++-
> src/gallium/state_trackers/glx/xlib/xm_api.c | 56 +++++++++++++--------------
> src/gallium/state_trackers/glx/xlib/xm_api.h | 2 +-
> 3 files changed, 33 insertions(+), 30 deletions(-)
>
> diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c
> index 1994e6823a..6ec3a31d5f 100644
> --- a/src/gallium/state_trackers/glx/xlib/glx_api.c
> +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
> @@ -743,7 +743,10 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
> int numAux = 0;
> GLint num_samples = 0;
>
> - xmesa_init( dpy );
> + if (xmesa_init( dpy ) != 0) {
> + _mesa_warning(NULL, "Failed to initialize display");
> + return NULL;
> + }
>
> parselist = list;
>
> diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
> index 934c0aba11..e8cbb618ce 100644
> --- a/src/gallium/state_trackers/glx/xlib/xm_api.c
> +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
> @@ -142,8 +142,11 @@ xmesa_close_display(Display *display)
> {
> XMesaExtDisplayInfo *info, *prev;
>
> + /* These assertions are not valid since screen creation can fail and result
> + * in an empty list
> assert(MesaExtInfo.ndisplays > 0);
> assert(MesaExtInfo.head);
> + */
>
Gut feeling suggests that this and perhaps the choose_visual() hunks
are signs of other preexisting bugs.
If you decide to stick around with xlib-glx it is worth nuking the
XMesa abstraction/API.
It hasn't been used in ages, it will help you simplify the whole thing
and squash a lot more lurking bugs.
HTH
Emil
More information about the mesa-dev
mailing list