Bug 52604 - External extensions are broken on 64 bit systems
Summary: External extensions are broken on 64 bit systems
Status: RESOLVED INVALID
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-27 20:05 UTC by Dr. Stefan Schimanski
Modified: 2018-06-13 17:57 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Dr. Stefan Schimanski 2012-07-27 20:05:37 UTC
If you build an extension outside of the xorg-server build system (e.g. following http://www.x.org/wiki/X11_Extension_tutorial), the resulting extension will fail on 64 bit systems with an BadLength error.

The reason the following: Outside of the xorg-server build system, the _XSERVER64 macro is not defined (it usually come from include/dix-config.h). In this case, the Mask type becomes 64 bit, although 32 bit is correct even on 64 bit systems.

Mask is used in the ClientRec struct. But due to the wrong size of Mask, the member alignment is broken: in the 3rdparty extension the Mask variables cause a different binary layout of the ClientRec struct than in the internal extensions.

Test case:

  #define _XSERVER64

  #include <X11/X.h>
  #include <X11/Xproto.h>
  #include <xorg/misc.h>
  #include <xorg/extnsionst.h>
  #include <xorg/dixstruct.h>

  int main(int argc, char **argv) {
    printf("%d\n", sizeof(Mask));
    printf("%d\n", sizeof(ClientRec));
  }

You get 4 and 304.

Now remove the _XSERVER64 definition. You get 8 and 312.
Comment 1 Alan Coopersmith 2012-07-31 05:32:20 UTC
There's also:

#ifdef _LP64
#define _XSERVER64 1
#endif

at the end of <xorg/xorg-server.h>, which works on Solaris at least.
(Apple has a different solution in dix-config-apple-verbatim.h -
 someday we should come up with a common solution for all OS'es.)
Comment 2 Adam Jackson 2018-06-13 17:57:05 UTC
That "extension tutorial" page no longer exists; as far as I can tell it never mentioned as much as the initial report here suggests.

Regardless, this is a misunderstanding. The server-side of the external extension would need to include <xorg-server.h> to get this right; mixing client-side and server-side code in the same source file is not supported, and if you want to be server side, you have to say so.


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.