Bug 179625 - x11-servers/xorg-server built with clang does not work, needs USE_GCC=any
Summary: x11-servers/xorg-server built with clang does not work, needs USE_GCC=any
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-x11 (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-16 21:50 UTC by Anton Shterenlikht
Modified: 2013-06-18 09:40 UTC (History)
0 users

See Also:


Attachments
llvm-pr16130.diff (14.46 KB, patch)
2013-06-17 12:13 UTC, Dimitry Andric
no flags Details | Diff
x11-servers__xorg-server__fix-xace-callback-1.diff (7.44 KB, patch)
2013-06-17 22:18 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Shterenlikht 2013-06-16 21:50:00 UTC
Briefly:
********

If x11-servers/xorg-server is built with clang (default),
it does not work, i.e. :

(EE) Jun 16 21:05:31 NVIDIA(0): Failed to initialize default colormap

Full details:
*************

I have this graphics card:

vgapci0@pci0:1:0:0:     class=0x030000 card=0x20d917aa chip=0x040c10de rev=0xa1 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device     = 'G84M [Quadro FX 570M]'
    class      = display
    subclass   = VGA

I built xorg-server from ports, using clang as the default compiler.

X -configure runs fine, producing /root/xorg.conf.new as:

Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
	ModulePath   "/usr/local/lib/xorg/modules"
	FontPath     "/usr/local/lib/X11/fonts/misc/"
	FontPath     "/usr/local/lib/X11/fonts/TTF/"
	FontPath     "/usr/local/lib/X11/fonts/OTF"
	FontPath     "/usr/local/lib/X11/fonts/Type1/"
	FontPath     "/usr/local/lib/X11/fonts/100dpi/"
	FontPath     "/usr/local/lib/X11/fonts/75dpi/"
EndSection

Section "Module"
	Load  "extmod"
	Load  "record"
	Load  "dbe"
	Load  "dri"
	Load  "dri2"
	Load  "glx"
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/sysmouse"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Device"
	Identifier  "Card0"
	Driver      "nvidia"
	VendorName  "NVIDIA Corporation"
	BoardName   "G84GLM [Quadro FX 570M]"
	BusID       "PCI:1:0:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     1
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     4
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     8
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     15
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection


Then

X -config /root/xorg.conf.new -retro

gives this error:

X.Org X Server 1.7.7
Release Date: 2010-05-04
X Protocol Version 11, Revision 0
Build Operating System: FreeBSD 10.0-CURRENT amd64 
Current Operating System: FreeBSD zzz.men.bris.ac.uk 10.0-CURRENT FreeBSD 10.0-CURRENT #4 r249781: Tue Apr 23 07:39:34 BST 2013     root@zzz.men.bris.ac.uk:/usr/obj/usr/src/sys/MINKY amd64
Build Date: 16 June 2013  09:02:14PM
 
Current version of pixman: 0.28.2
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sun Jun 16 21:05:25 2013
(++) Using config file: "/root/xorg.conf.new"
(==) ServerLayout "X.org Configured"
(**) |-->Screen "Screen0" (0)
(**) |   |-->Monitor "Monitor0"
(**) |   |-->Device "Card0"
(**) |-->Input Device "Mouse0"
(**) |-->Input Device "Keyboard0"
(==) Automatically adding devices
(==) Automatically enabling devices
(**) FontPath set to:
	/usr/local/lib/X11/fonts/misc/,
	/usr/local/lib/X11/fonts/TTF/,
	/usr/local/lib/X11/fonts/OTF,
	/usr/local/lib/X11/fonts/Type1/,
	/usr/local/lib/X11/fonts/100dpi/,
	/usr/local/lib/X11/fonts/75dpi/,
	/usr/local/lib/X11/fonts/misc/,
	/usr/local/lib/X11/fonts/TTF/,
	/usr/local/lib/X11/fonts/OTF,
	/usr/local/lib/X11/fonts/Type1/,
	/usr/local/lib/X11/fonts/100dpi/,
	/usr/local/lib/X11/fonts/75dpi/
(**) ModulePath set to "/usr/local/lib/xorg/modules"
(WW) AllowEmptyInput is on, devices using drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.
(WW) Disabling Mouse0
(WW) Disabling Keyboard0
(II) Loader magic: 0x7b6a50
(II) Module ABI versions:
	X.Org ANSI C Emulation: 0.4
	X.Org Video Driver: 6.0
	X.Org XInput driver : 7.0
	X.Org Server Extension : 2.0
(--) Using syscons driver with X support (version 2.0)
(--) using VT number 9

(--) PCI:*(0:1:0:0) 10de:040c:17aa:20d9 NVIDIA Corporation G84GLM [Quadro FX 570M] rev 161, Mem @ 0xd6000000/16777216, 0xe0000000/268435456, 0xd4000000/33554432, I/O @ 0x00002000/128, BIOS @ 0x????????/65536
(II) "extmod" will be loaded. This was enabled by default and also specified in the config file.
(II) "dbe" will be loaded. This was enabled by default and also specified in the config file.
(II) "glx" will be loaded. This was enabled by default and also specified in the config file.
(II) "record" will be loaded. This was enabled by default and also specified in the config file.
(II) "dri" will be loaded. This was enabled by default and also specified in the config file.
(II) "dri2" will be loaded. This was enabled by default and also specified in the config file.
(II) LoadModule: "extmod"
(II) Loading /usr/local/lib/xorg/modules/extensions/libextmod.so
(II) Module extmod: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	Module class: X.Org Server Extension
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension MIT-SCREEN-SAVER
(II) Loading extension XFree86-VidModeExtension
(II) Loading extension XFree86-DGA
(II) Loading extension DPMS
(II) Loading extension XVideo
(II) Loading extension XVideo-MotionCompensation
(II) Loading extension X-Resource
(II) LoadModule: "record"
(II) Loading /usr/local/lib/xorg/modules/extensions/librecord.so
(II) Module record: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.13.0
	Module class: X.Org Server Extension
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension RECORD
(II) LoadModule: "dbe"
(II) Loading /usr/local/lib/xorg/modules/extensions/libdbe.so
(II) Module dbe: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	Module class: X.Org Server Extension
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension DOUBLE-BUFFER
(II) LoadModule: "dri"
(II) Loading /usr/local/lib/xorg/modules/extensions/libdri.so
(II) Module dri: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension XFree86-DRI
(II) LoadModule: "dri2"
(II) Loading /usr/local/lib/xorg/modules/extensions/libdri2.so
(II) Module dri2: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.1.0
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension DRI2
(II) LoadModule: "glx"
(II) Loading /usr/local/lib/xorg/modules/extensions/libglx.so
(II) Module glx: vendor="NVIDIA Corporation"
	compiled for 4.0.2, module version = 1.0.0
	Module class: X.Org Server Extension
(II) NVIDIA GLX Module  310.44  Wed Mar 27 15:00:45 PDT 2013
(II) Loading extension GLX
(II) LoadModule: "nvidia"
(II) Loading /usr/local/lib/xorg/modules/drivers/nvidia_drv.so
(II) Module nvidia: vendor="NVIDIA Corporation"
	compiled for 4.0.2, module version = 1.0.0
	Module class: X.Org Video Driver
(II) NVIDIA dlloader X Driver  310.44  Wed Mar 27 14:44:32 PDT 2013
(II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
(II) Primary Device is: PCI 01@00:00:0
(II) Loading sub module "wfb"
(II) LoadModule: "wfb"
(II) Loading /usr/local/lib/xorg/modules/libwfb.so
(II) Module wfb: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	ABI class: X.Org ANSI C Emulation, version 0.4
(II) Loading sub module "ramdac"
(II) LoadModule: "ramdac"
(II) Module "ramdac" already built-in
(WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
(==) NVIDIA(0): Depth 24, (==) framebuffer bpp 32
(==) NVIDIA(0): RGB weight 888
(==) NVIDIA(0): Default visual is TrueColor
(==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)
(**) Jun 16 21:05:25 NVIDIA(0): Enabling 2D acceleration
(II) Jun 16 21:05:29 NVIDIA(0): NVIDIA GPU Quadro FX 570M (G84GL) at PCI:1:0:0 (GPU-0)
(--) Jun 16 21:05:29 NVIDIA(0): Memory: 524288 kBytes
(--) Jun 16 21:05:29 NVIDIA(0): VideoBIOS: 60.84.51.00.00
(II) Jun 16 21:05:29 NVIDIA(0): Detected PCI Express Link width: 16X
(--) Jun 16 21:05:29 NVIDIA(0): Valid display device(s) on Quadro FX 570M at PCI:1:0:0
(--) Jun 16 21:05:29 NVIDIA(0):     CRT-0
(--) Jun 16 21:05:29 NVIDIA(0):     IBM (DFP-0) (connected)
(--) Jun 16 21:05:29 NVIDIA(0):     DFP-1
(--) Jun 16 21:05:29 NVIDIA(0): CRT-0: 400.0 MHz maximum pixel clock
(--) Jun 16 21:05:29 NVIDIA(0): IBM (DFP-0): 330.0 MHz maximum pixel clock
(--) Jun 16 21:05:29 NVIDIA(0): IBM (DFP-0): Internal Dual Link LVDS
(--) Jun 16 21:05:29 NVIDIA(0): DFP-1: 330.0 MHz maximum pixel clock
(--) Jun 16 21:05:29 NVIDIA(0): DFP-1: Internal Single Link TMDS
(**) Jun 16 21:05:29 NVIDIA(0): Using HorizSync/VertRefresh ranges from the EDID for display
(**) Jun 16 21:05:29 NVIDIA(0):     device IBM (DFP-0) (Using EDID frequencies has been
(**) Jun 16 21:05:29 NVIDIA(0):     enabled on all display devices.)
(==) Jun 16 21:05:29 NVIDIA(0): 
(==) Jun 16 21:05:29 NVIDIA(0): No modes were requested; the default mode "nvidia-auto-select"
(==) Jun 16 21:05:29 NVIDIA(0):     will be used as the requested mode.
(==) Jun 16 21:05:29 NVIDIA(0): 
(II) Jun 16 21:05:29 NVIDIA(0): Validated MetaModes:
(II) Jun 16 21:05:29 NVIDIA(0):     "DFP-0:nvidia-auto-select"
(II) Jun 16 21:05:29 NVIDIA(0): Virtual screen size determined to be 1680 x 1050
(--) Jun 16 21:05:31 NVIDIA(0): DPI set to (129, 127); computed from "UseEdidDpi" X config
(--) Jun 16 21:05:31 NVIDIA(0):     option
(WW) Jun 16 21:05:31 NVIDIA(0): UBB is incompatible with the Composite extension.  Disabling
(WW) Jun 16 21:05:31 NVIDIA(0):     UBB.
(--) Depth 24 pixmap format is 32 bpp
(II) Jun 16 21:05:31 NVIDIA: Reserving 768.00 MB of virtual memory for indirect memory
(II) Jun 16 21:05:31 NVIDIA:     access.
(II) Jun 16 21:05:31 NVIDIA(0): Setting mode "DFP-0:nvidia-auto-select"
(II) Loading extension NV-GLX
(==) NVIDIA(0): Disabling shared memory pixmaps
(==) NVIDIA(0): Backing store disabled
(==) NVIDIA(0): Silken mouse enabled
(EE) Jun 16 21:05:31 NVIDIA(0): Failed to initialize default colormap
(EE) NVIDIA(0):  *** Aborting ***

Fatal server error:
AddScreen/ScreenInit failed for driver 0


Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
Please also check the log file at "/var/log/Xorg.0.log" for additional information.

Fix: 

Rebuilding xorg-server with USE_GCC=any helps.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-06-17 00:57:46 UTC
Responsible Changed
From-To: freebsd-amd64->freebsd-x11

reclassify and assign.
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2013-06-17 12:13:40 UTC
As Jung-uk Kim points out in his reply to the thread about this bug on
-current <http://docs.freebsd.org/cgi/mid.cgi?51BB5F3A.60504>, this may
be due to a clang optimizer bug, specifically LLVM PR 16130
<http://llvm.org/bugs/show_bug.cgi?id=16130>.

Can you please verify it is exactly this bug, by applying the attached
patch to your r249781 tree (I assume you have not yet upgraded), then
rebuild clang by doing:

   cd /usr/src/lib/clang && make
   cd /usr/src/usr.bin/clang && make && sudo make install

After the patched clang has been installed, rebuild your xorg-server
without the USE_GCC=any setting, and check if the startup problem was
resolved.

-Dimitry
Comment 3 Anton Shterenlikht 2013-06-17 13:00:48 UTC
The patch applied cleanly (yes, I'm still on r249781).
The commands you wrote also run with no problems.
However, rebuilding xorg-server with patched clang,
and removing USE_GCC, did not help. The X error
is still the same:

(EE) Jun 17 12:51:23 NVIDIA(0): Failed to initialize default colormap
(EE) NVIDIA(0):  *** Aborting ***

Fatal server error:
AddScreen/ScreenInit failed for driver 0

Anton
Comment 4 paul.brewer40 2013-06-17 21:20:54 UTC
I too have this issue.

When xorg-server is compiled with clang, the following appears in /var/log/Xorg.0.log:

----------------------------------------------------------------------
<everything looks normal up to this point>
(II) VBoxVideo(0): Using default gamma of (1.0, 1.0, 1.0) unless 
otherwise stated.
(II) VBoxVideo(0): RandR 1.2 enabled, ignore the following RandR disabled 
message.

Fatal server error:
AddScreen/ScreenInit failed for driver 0


Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
Please also check the log file at "/var/log/Xorg.0.log" for additional 
information.

Segmentation fault at address 0x290
----------------------------------------------------------------------
This is in a VM, which reports the graphics adapter as:

vgapci0@pci0:0:2:0:	class=0x030000 card=0x00000000 chip=0xbeef80ee 
rev=0x00 hdr=0x00
    vendor     = 'InnoTek Systemberatung GmbH'
    device     = 'VirtualBox Graphics Adapter'
    class      = display
    subclass   = VGA
Comment 5 Dimitry Andric freebsd_committer freebsd_triage 2013-06-17 22:18:43 UTC
On Jun 17, 2013, at 14:00, Anton Shterenlikht <mexas@bris.ac.uk> wrote:
> The patch applied cleanly (yes, I'm still on r249781).
> The commands you wrote also run with no problems.
> However, rebuilding xorg-server with patched clang,
> and removing USE_GCC, did not help. The X error
> is still the same:
> 
> (EE) Jun 17 12:51:23 NVIDIA(0): Failed to initialize default colormap
> (EE) NVIDIA(0):  *** Aborting ***
> 
> Fatal server error:
> AddScreen/ScreenInit failed for driver 0


Okay, so the optimizer was not the issue then. :-)

Luckily I was able to reproduce your error, after realizing you were
using the old X.org server (version 1.7.7).  As far as I can tell, this
is the following bug:

  https://bugs.freedesktop.org/show_bug.cgi?id=18451

which is fixed by this commit:

  http://cgit.freedesktop.org/xorg/xserver/commit/?id=6dae7f3792611aace1df0cca63bf50c50d93de43

I'm attaching a diff for our x11-servers/xorg-server port, can you
please try it?  E.g. from the root of your ports tree, run:

  patch -p0 -f -F0 -i x11-servers__xorg-server__fix-xace-callback-1.diff

which should modify x11-servers/xorg-server/Makefile, and add an
additional patch (extra-Xext-xace.c) to the files subdirectory.  Then
rebuild and reinstall the xorg-server port.

-Dimitry
Comment 6 Jung-uk Kim freebsd_committer freebsd_triage 2013-06-17 22:46:37 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-06-17 17:18:43 -0400, Dimitry Andric wrote:
> Luckily I was able to reproduce your error, after realizing you
> were using the old X.org server (version 1.7.7).  As far as I can
> tell, this is the following bug:
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=18451
> 
> which is fixed by this commit:
> 
> http://cgit.freedesktop.org/xorg/xserver/commit/?id=6dae7f3792611aace1df0cca63bf50c50d93de43
...

Yes,
> 
that did it!  Thanks for the nice detective work!

Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (FreeBSD)

iQEcBAEBAgAGBQJRv4O9AAoJECXpabHZMqHOqHoIAIzq09axU9KP+OapYffHhM0G
LrBSLQt0eBUzAKeNAbxGCh243zmvSv8GKt503JQf01IOtUlf1C3nh2htKiskH0Gw
5Y2hxU8obv4dQqhj2VfM2N3YshNMIwzVv+BRuR+jRZXwkO6AzhG3QetbS4j24yhl
QgoU/9xKznqK3DG/dMS1UhiPSIBXEtPJQydQJqENOFNWF1vfLLFnyeRqlh9/CXxn
1EsHm+Vck1c/HOID0v7yajjBazOQmlSVNqmX6YPDsaDqa4OeZ9OKFAXM9bk2Fcjf
xXPJWiFBxHrgdVx01X2zdPSRut4pxfIBXXC70fMy2/wwdxauxgOmEMWbNkJOPm4=
=Fm1K
-----END PGP SIGNATURE-----
Comment 7 dfilter service freebsd_committer freebsd_triage 2013-06-17 22:51:57 UTC
Author: jkim
Date: Mon Jun 17 21:51:48 2013
New Revision: 321157
URL: http://svnweb.freebsd.org/changeset/ports/321157

Log:
  Add a patch to fix upstream bug 18451 for 1.7.7.
  
  https://bugs.freedesktop.org/show_bug.cgi?id=18451
  http://cgit.freedesktop.org/xorg/xserver/patch/?id=6dae7f3
  
  Analyzed by:	dim
  PR:		ports/179625

Added:
  head/x11-servers/xorg-server/files/extra-Xext-xace.c   (contents, props changed)
Modified:
  head/x11-servers/xorg-server/Makefile

Modified: head/x11-servers/xorg-server/Makefile
==============================================================================
--- head/x11-servers/xorg-server/Makefile	Mon Jun 17 21:37:24 2013	(r321156)
+++ head/x11-servers/xorg-server/Makefile	Mon Jun 17 21:51:48 2013	(r321157)
@@ -27,12 +27,13 @@ PLIST_SUB+=	OLD="@comment " NEW=""
 EXTRA_PATCHES+=	${FILESDIR}/extra-clang
 .else
 XORG_VERSION=	1.7.7
-XORG_REVISION=	6
+XORG_REVISION=	7
 PLIST_SUB+=	OLD="" NEW="@comment "
-EXTRA_PATCHES+=	${FILESDIR}/extra-include_eventstr.h \
-		${FILESDIR}/extra-os-utils.c \
+EXTRA_PATCHES+=	${FILESDIR}/extra-Xext-xace.c \
 		${FILESDIR}/extra-Xserver-hw-xfree86-os-support-bsd-sparc64_video.c \
 		${FILESDIR}/extra-Xserver-os-xprintf.c \
+		${FILESDIR}/extra-include_eventstr.h \
+		${FILESDIR}/extra-os-utils.c \
 		${FILESDIR}/extra-servermd.h
 .endif
 

Added: head/x11-servers/xorg-server/files/extra-Xext-xace.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11-servers/xorg-server/files/extra-Xext-xace.c	Mon Jun 17 21:51:48 2013	(r321157)
@@ -0,0 +1,229 @@
+From 6dae7f3792611aace1df0cca63bf50c50d93de43 Mon Sep 17 00:00:00 2001
+From: Chris Wilson <chris@chris-wilson.co.uk>
+Date: Tue, 10 Aug 2010 18:30:20 +0000
+Subject: xace: Invalid reference to out-of-scope data.
+
+The callback data passed by reference to the hook was allocated on stack
+within the scope of the case statement. The compiler is free to reuse
+any of that stack space whilst making the function call so we may end up
+passing garbage into the callback.
+
+References:
+
+  Bug 18451 - Xorg server 1.5.2 SEGV during XFixesGetCursorImage()
+  https://bugs.freedesktop.org/show_bug.cgi?id=18451
+
+v2: Drop the unrelated hunk that snuck in when ammending the commit
+message.
+
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+Signed-off-by: Keith Packard <keithp@keithp.com>
+---
+diff --git a/Xext/xace.c b/Xext/xace.c
+index e10d837..c757cad 100644
+--- Xext/xace.c
++++ Xext/xace.c
+@@ -87,7 +87,18 @@ void XaceHookAuditEnd(ClientPtr ptr, int result)
+  */
+ int XaceHook(int hook, ...)
+ {
+-    pointer calldata;	/* data passed to callback */
++    union {
++	XaceResourceAccessRec res;
++	XaceDeviceAccessRec dev;
++	XaceSendAccessRec send;
++	XaceReceiveAccessRec recv;
++	XaceClientAccessRec client;
++	XaceExtAccessRec ext;
++	XaceServerAccessRec server;
++	XaceScreenAccessRec screen;
++	XaceAuthAvailRec auth;
++	XaceKeyAvailRec key;
++    } u;
+     int *prv = NULL;	/* points to return value from callback */
+     va_list ap;		/* argument list */
+     va_start(ap, hook);
+@@ -99,117 +110,86 @@ int XaceHook(int hook, ...)
+      */
+     switch (hook)
+     {
+-	case XACE_RESOURCE_ACCESS: {
+-	    XaceResourceAccessRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.id = va_arg(ap, XID);
+-	    rec.rtype = va_arg(ap, RESTYPE);
+-	    rec.res = va_arg(ap, pointer);
+-	    rec.ptype = va_arg(ap, RESTYPE);
+-	    rec.parent = va_arg(ap, pointer);
+-	    rec.access_mode = va_arg(ap, Mask);
+-	    rec.status = Success; /* default allow */
+-	    calldata = &rec;
+-	    prv = &rec.status;
++	case XACE_RESOURCE_ACCESS:
++	    u.res.client = va_arg(ap, ClientPtr);
++	    u.res.id = va_arg(ap, XID);
++	    u.res.rtype = va_arg(ap, RESTYPE);
++	    u.res.res = va_arg(ap, pointer);
++	    u.res.ptype = va_arg(ap, RESTYPE);
++	    u.res.parent = va_arg(ap, pointer);
++	    u.res.access_mode = va_arg(ap, Mask);
++	    u.res.status = Success; /* default allow */
++	    prv = &u.res.status;
+ 	    break;
+-	}
+-	case XACE_DEVICE_ACCESS: {
+-	    XaceDeviceAccessRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.dev = va_arg(ap, DeviceIntPtr);
+-	    rec.access_mode = va_arg(ap, Mask);
+-	    rec.status = Success; /* default allow */
+-	    calldata = &rec;
+-	    prv = &rec.status;
++	case XACE_DEVICE_ACCESS:
++	    u.dev.client = va_arg(ap, ClientPtr);
++	    u.dev.dev = va_arg(ap, DeviceIntPtr);
++	    u.dev.access_mode = va_arg(ap, Mask);
++	    u.dev.status = Success; /* default allow */
++	    prv = &u.dev.status;
+ 	    break;
+-	}
+-	case XACE_SEND_ACCESS: {
+-	    XaceSendAccessRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.dev = va_arg(ap, DeviceIntPtr);
+-	    rec.pWin = va_arg(ap, WindowPtr);
+-	    rec.events = va_arg(ap, xEventPtr);
+-	    rec.count = va_arg(ap, int);
+-	    rec.status = Success; /* default allow */
+-	    calldata = &rec;
+-	    prv = &rec.status;
++	case XACE_SEND_ACCESS:
++	    u.send.client = va_arg(ap, ClientPtr);
++	    u.send.dev = va_arg(ap, DeviceIntPtr);
++	    u.send.pWin = va_arg(ap, WindowPtr);
++	    u.send.events = va_arg(ap, xEventPtr);
++	    u.send.count = va_arg(ap, int);
++	    u.send.status = Success; /* default allow */
++	    prv = &u.send.status;
+ 	    break;
+-	}
+-	case XACE_RECEIVE_ACCESS: {
+-	    XaceReceiveAccessRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.pWin = va_arg(ap, WindowPtr);
+-	    rec.events = va_arg(ap, xEventPtr);
+-	    rec.count = va_arg(ap, int);
+-	    rec.status = Success; /* default allow */
+-	    calldata = &rec;
+-	    prv = &rec.status;
++	case XACE_RECEIVE_ACCESS:
++	    u.recv.client = va_arg(ap, ClientPtr);
++	    u.recv.pWin = va_arg(ap, WindowPtr);
++	    u.recv.events = va_arg(ap, xEventPtr);
++	    u.recv.count = va_arg(ap, int);
++	    u.recv.status = Success; /* default allow */
++	    prv = &u.recv.status;
+ 	    break;
+-	}
+-	case XACE_CLIENT_ACCESS: {
+-	    XaceClientAccessRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.target = va_arg(ap, ClientPtr);
+-	    rec.access_mode = va_arg(ap, Mask);
+-	    rec.status = Success; /* default allow */
+-	    calldata = &rec;
+-	    prv = &rec.status;
++	case XACE_CLIENT_ACCESS:
++	    u.client.client = va_arg(ap, ClientPtr);
++	    u.client.target = va_arg(ap, ClientPtr);
++	    u.client.access_mode = va_arg(ap, Mask);
++	    u.client.status = Success; /* default allow */
++	    prv = &u.client.status;
+ 	    break;
+-	}
+-	case XACE_EXT_ACCESS: {
+-	    XaceExtAccessRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.ext = va_arg(ap, ExtensionEntry*);
+-	    rec.access_mode = DixGetAttrAccess;
+-	    rec.status = Success; /* default allow */
+-	    calldata = &rec;
+-	    prv = &rec.status;
++	case XACE_EXT_ACCESS:
++	    u.ext.client = va_arg(ap, ClientPtr);
++	    u.ext.ext = va_arg(ap, ExtensionEntry*);
++	    u.ext.access_mode = DixGetAttrAccess;
++	    u.ext.status = Success; /* default allow */
++	    prv = &u.ext.status;
+ 	    break;
+-	}
+-	case XACE_SERVER_ACCESS: {
+-	    XaceServerAccessRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.access_mode = va_arg(ap, Mask);
+-	    rec.status = Success; /* default allow */
+-	    calldata = &rec;
+-	    prv = &rec.status;
++	case XACE_SERVER_ACCESS:
++	    u.server.client = va_arg(ap, ClientPtr);
++	    u.server.access_mode = va_arg(ap, Mask);
++	    u.server.status = Success; /* default allow */
++	    prv = &u.server.status;
+ 	    break;
+-	}
+ 	case XACE_SCREEN_ACCESS:
+-	case XACE_SCREENSAVER_ACCESS: {
+-	    XaceScreenAccessRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.screen = va_arg(ap, ScreenPtr);
+-	    rec.access_mode = va_arg(ap, Mask);
+-	    rec.status = Success; /* default allow */
+-	    calldata = &rec;
+-	    prv = &rec.status;
++	case XACE_SCREENSAVER_ACCESS:
++	    u.screen.client = va_arg(ap, ClientPtr);
++	    u.screen.screen = va_arg(ap, ScreenPtr);
++	    u.screen.access_mode = va_arg(ap, Mask);
++	    u.screen.status = Success; /* default allow */
++	    prv = &u.screen.status;
+ 	    break;
+-	}
+-	case XACE_AUTH_AVAIL: {
+-	    XaceAuthAvailRec rec;
+-	    rec.client = va_arg(ap, ClientPtr);
+-	    rec.authId = va_arg(ap, XID);
+-	    calldata = &rec;
++	case XACE_AUTH_AVAIL:
++	    u.auth.client = va_arg(ap, ClientPtr);
++	    u.auth.authId = va_arg(ap, XID);
+ 	    break;
+-	}
+-	case XACE_KEY_AVAIL: {
+-	    XaceKeyAvailRec rec;
+-	    rec.event = va_arg(ap, xEventPtr);
+-	    rec.keybd = va_arg(ap, DeviceIntPtr);
+-	    rec.count = va_arg(ap, int);
+-	    calldata = &rec;
++	case XACE_KEY_AVAIL:
++	    u.key.event = va_arg(ap, xEventPtr);
++	    u.key.keybd = va_arg(ap, DeviceIntPtr);
++	    u.key.count = va_arg(ap, int);
+ 	    break;
+-	}
+-	default: {
++	default:
+ 	    va_end(ap);
+ 	    return 0;	/* unimplemented hook number */
+-	}
+     }
+     va_end(ap);
+  
+     /* call callbacks and return result, if any. */
+-    CallCallbacks(&XaceHooks[hook], calldata);
++    CallCallbacks(&XaceHooks[hook], &u);
+     return prv ? *prv : Success;
+ }
+ 
+--
+cgit v0.9.0.2-2-gbebe
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 8 Jung-uk Kim freebsd_committer freebsd_triage 2013-06-17 22:54:15 UTC
State Changed
From-To: open->closed

Committed (r321157), thanks!
Comment 9 Anton Shterenlikht 2013-06-18 09:29:13 UTC
Yes, this fixed the issue for me too, thank you.

Shall I revert the clang patch?

Thanks

Anton