Bug 24581

Summary: libXext 1.0.5/extutil.c line 127
Product: xorg Reporter: John Bowler <jbowler>
Component: Lib/XextAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED NOTABUG QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: jbowler, peter.hutterer
Version: 7.4 (2008.09)   
Hardware: Other   
OS: All   
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 16399    

Description John Bowler 2009-10-16 19:35:12 UTC
This line, number 127 in Xext 1.0.5 extutil.c, looks wrong:

        /* register extension for XGE */
        if (strcmp(ext_name, GE_NAME))
            xgeExtRegister(dpy, dpyinfo->codes->major_opcode, hooks);

If it's right it deserves an explanation as to why the extension is registered for every call to XextAddDisplay where ext_name != <GE_NAME>

The net effect seems to be to call 'xgeExtRegister' only if the server has at least one different extension.

The observed problem is that when I connect an application that does not require this extension to an Xming server (that doesn't have it) I get spurious poo on stderr:

Xlib:  extension "Generic Event Extension" missing on display "grayback.kalmiopsis:0.0".

Backtrace, somewhat denuded, is:

gdb) backtrace
#0  0xb7cb96e6 in fprintf () from /lib/libc.so.6
#1  0xb6bc26be in ?? () from /usr/lib/libXext.so.6
#2  0xb7db1560 in ?? () from /lib/libc.so.6
#3  0xb6bc2cdd in ?? () from /usr/lib/libXext.so.6
#4  0xb6bc42f0 in ?? () from /usr/lib/libXext.so.6
#5  0xb6bc2cd5 in ?? () from /usr/lib/libXext.so.6
#6  0x082c7098 in ?? ()
#7  0xb6bb7000 in ?? ()
#8  0x0000d038 in ?? ()
#9  0x00000001 in ?? ()
#10 0xb6bb8a20 in ?? () from /usr/lib/libXext.so.6
#11 0xb6bc3ff4 in ?? () from /usr/lib/libXext.so.6
#12 0xb6bc3ff4 in ?? () from /usr/lib/libXext.so.6
#13 0xb6bc2683 in XMissingExtension () from /usr/lib/libXext.so.6
#14 0xb6bc42f0 in ?? () from /usr/lib/libXext.so.6
#15 0xb6bc2cd5 in ?? () from /usr/lib/libXext.so.6
#16 0xb6bc2643 in XSetExtensionErrorHandler () from /usr/lib/libXext.so.6
#17 0xb6bc3ff4 in ?? () from /usr/lib/libXext.so.6
#18 0xb6bc217f in _xgeCheckExtInit () from /usr/lib/libXext.so.6
#19 0xb6bb9645 in ?? () from /usr/lib/libXext.so.6
Comment 1 John Bowler 2009-10-16 19:58:33 UTC
I've confirmed (on an up-to-date gentoo) that the obvious change to the strcmp test does fix the problem (i.e. stderr is no longer spewing spurious warnings.)
Comment 2 Peter Hutterer 2009-10-18 16:47:51 UTC
commit 850263ac9f772ab80f3e0680997f00e0c566f7d4
Author:     Peter Hutterer <peter@cs.unisa.edu.au>
AuthorDate: Tue May 15 17:00:07 2007 +0930

    Add GenericEvent extension (XGE).

    Automatically register any extension at XGE and relay events to
    the extension's event handlers.

The reason we register it for any extension is to slot in XGE automatically. GenericEvents re-use the opcode 35, so you can't have multiple extensions register for the same event. Instead, you only register XGE on this opcode and that passes the events on pending on the event's extension opcode.

So instead of 
event on wire - libX11 checks opcode - call extension registered handler
it needs to be
event on wire - libX11 checks opcode - call XGE-registered handler - XGE checks extension opcode - call extension-registered handler

Doing so requires either adding a new API and then changing all libraries, or to simply register every extension with XGE automatically. This is what 850263ac9f did. The error message is a side-effect of registering the extension and has been silenced with 
commit 8a91fc6f72206362f399b5e29bf3d5f44f4eb822
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Feb 10 07:45:32 2009 +1000

    Silence "Generic Event Extension missing on display" warning.
    If we're already doing a check anyway, we don't need to print an extra

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.