[PATCH] xorg-gtest: fix registering error handlers

Maarten Lankhorst maarten.lankhorst at canonical.com
Fri Feb 1 00:09:56 PST 2013


Op 01-02-13 01:42, Peter Hutterer schreef:
> 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.
>
I think it's due to lazy symbol lookup, old_handler correctly points to _XDefaultIOError, but when
I print the pointer to _XDefaultIOError before the call it points to something different, presumably to
some stub that would look up _XDefaultIOError.

When I added a breakpoint in the debug branch, and printed out old_handler and _XDefaultIOError,
it would happily print that they were equal, so the only logical explanation is that the application
had a different pointer for _XDefaultIOError than the library did. That's not to say either is incorrect,
but it is likely that the application's pointer pointed to a stub that would do the symbol lookup then
call the real function.

~Maarten



More information about the xorg-devel mailing list