Subject: Xrender and 64bit
To: None <tech-x11@netbsd.org>
From: Michael <macallan18@earthlink.net>
List: tech-x11
Date: 07/24/2005 14:21:42
--Signature_Sun__24_Jul_2005_14_21_42_-0400_+nshqCD29ZFaZl.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

Hello,

I recently found out that whoever wrote Xrender apparently didn't waste
a single thought on 64bit systems. Base types are unsigned longs ( see
X11/extensions/render.h ):

typedef unsigned long	Glyph;
typedef unsigned long	GlyphSet;
typedef unsigned long	Picture;
typedef unsigned long	PictFormat;

but everything seems to assume they're size 4 bytes and goes some
lengths to ensure 4 byte alignment but this still leads to occasional
SIGBUS from Xserver/render/render.c, especially
ProcRenderCompositeGlyph(). A quick, working but dead ugly 'fix' is
this:=20

Index: render.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/render/render.c,v
retrieving revision 1.1.1.6 diff -u -w -r1.1.1.6 render.c=20
--- render.c 18 Mar 2005 13:13:16 -0000      1.1.1.6=20
+++ render.c    24 Jul 2005 17:46:09 -0000=20
@@ -1300,7 +1300,7 @@
        {
            if (buffer + sizeof (GlyphSet) < end)
            {
-               gs =3D *(GlyphSet *) buffer;
+               gs =3D *(CARD32 *) buffer;
                glyphSet =3D (GlyphSetPtr) SecurityLookupIDByType (client,
                                                                 gs,
                                               			 GlyphSetType,=20

A real fix would be to change the base types to something that's always
32bit I think but that would disrupt more or less everything that uses
Xrender since they're exposed to clients.

Any ideas what to do about this? On sparc64 this leads to firefox
occasionally crashing the Xserver and I'm pretty sure it would affect
other 64bit architectures as well.

have fun
Michael

--Signature_Sun__24_Jul_2005_14_21_42_-0400_+nshqCD29ZFaZl.0
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (NetBSD)

iQEVAwUBQuPcNspnzkX8Yg2nAQLD4gf+OhfA29wUvU48bNIJ/D+0jjNWSDY5I2At
b318cYi9indlSoJb4q7HqMgJC9FC2z928gw1z0kLsmWo1TjP0QZiIsh7WnmZ8UIm
YWCSN3d5ov2WgH9zW8kdhpCCQDoWk4kpmjqY4vQNvC0zOFXXx2MgSuO1tMvfBF2k
0B1/SyjhkcabgUclEbSEtMjRYmDm2pv2g8qEGZ8F7vjpdEXKCIQg2kEjhDHvTR6J
PmgHlACDoihUfqyrd1tLjJDVGfsrkBBLuUNlq0ZiWBxEkXTLyUuUt5qvhSYXRNYH
lxbi0G0KOrW0tDRSi0mWlhYv/PZLd2KySVBvqgEYm/5m/jJRUll04Q==
=yyNg
-----END PGP SIGNATURE-----

--Signature_Sun__24_Jul_2005_14_21_42_-0400_+nshqCD29ZFaZl.0--