[PATCH] xorg-gtest: fix registering error handlers

Peter Hutterer peter.hutterer at who-t.net
Thu Jan 31 16:42:27 PST 2013


On Thu, Jan 31, 2013 at 03:55:57PM +0100, Maarten Lankhorst wrote:
> It looks like xorg-gtest and libX11 have a different idea of where the error handler pointer is supposed to point at.
> Check for the default handler returned from XSet*ErrorHandler by setting a NULL error handler first.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at canonical.com>
> ---
> Probably some funny interaction with symbol lookup, presumably
> _XDefault*Error points to some stub first or something,
> 
> I don't really want to know, but it fixes up xorg-gtest 0.7.0
> enough to make it run all selftests again on precise.

You'll need to figure out why this doesn't work on precise. XOpenDisplay()
calls XSetErrorHandler(NULL) if _XErrorFunction is NULL, which will install
the default error handler. And _XErrorFunction should only be non-NULL if
something else has set it already. So something is out-of-order here and we
need to figure out what.

Cheers,
   Peter

> 
> diff --git a/src/xserver.cpp b/src/xserver.cpp
> index def6a89..a36ca7e 100644
> --- a/src/xserver.cpp
> +++ b/src/xserver.cpp
> @@ -436,19 +436,27 @@ static int _x_io_error_handler(Display *dpy)
>  
>  void xorg::testing::XServer::RegisterXIOErrorHandler()
>  {
> -  XIOErrorHandler old_handler;
> -  old_handler = XSetIOErrorHandler(_x_io_error_handler);
> +  XIOErrorHandler old_handler, def_handler;
>  
> -  if (old_handler != _XDefaultIOError)
> +  old_handler = XSetIOErrorHandler(NULL);
> +  def_handler = XSetIOErrorHandler(_x_io_error_handler);
> +
> +  if (old_handler != def_handler &&
> +      old_handler != _XDefaultIOError &&
> +      old_handler != _x_io_error_handler)
>      XSetIOErrorHandler(old_handler);
>  }
>  
>  void xorg::testing::XServer::RegisterXErrorHandler()
>  {
> -  XErrorHandler old_handler;
> -  old_handler = XSetErrorHandler(_x_error_handler);
> +  XErrorHandler old_handler, def_handler;
> +
> +  old_handler = XSetErrorHandler(NULL);
> +  def_handler = XSetErrorHandler(_x_error_handler);
>  
> -  if (old_handler != _XDefaultError)
> +  if (old_handler != def_handler &&
> +      old_handler != _XDefaultError &&
> +      old_handler != _x_error_handler)
>      XSetErrorHandler(old_handler);
>  }
>  
> 


More information about the xorg-devel mailing list