public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: x11-libs/libX11/files/, x11-libs/libX11/
@ 2022-11-25  6:05 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2022-11-25  6:05 UTC (permalink / raw
  To: gentoo-commits

commit:     eeb3b760c6031ad77d1deeceef1d5cca3714a6d4
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 25 06:04:05 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Nov 25 06:04:05 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eeb3b760

x11-libs/libX11: backport another reentrancy fix

Closes: https://bugs.gentoo.org/862115
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../libX11/files/libX11-1.8.2-reentrancy.patch     | 149 +++++++++++++++++++++
 x11-libs/libX11/libX11-1.8.2-r1.ebuild             |  48 +++++++
 2 files changed, 197 insertions(+)

diff --git a/x11-libs/libX11/files/libX11-1.8.2-reentrancy.patch b/x11-libs/libX11/files/libX11-1.8.2-reentrancy.patch
new file mode 100644
index 000000000000..784adaeb008f
--- /dev/null
+++ b/x11-libs/libX11/files/libX11-1.8.2-reentrancy.patch
@@ -0,0 +1,149 @@
+https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/a9e845809bcaae22496bc8aa3ca252b410d5f39b
+https://bugs.gentoo.org/862115
+
+From a9e845809bcaae22496bc8aa3ca252b410d5f39b Mon Sep 17 00:00:00 2001
+From: Matthieu Herrb <matthieu@herrb.eu>
+Date: Fri, 11 Nov 2022 18:55:23 +0100
+Subject: [PATCH] Fix 797755 Allow X*IfEvent() to reenter libX11
+
+- the activation logic is reversed
+- there is also _XInternalLockDisplay() that needs protection
+- I've found cases (in fvwm2) where the callback calls XCheckIfEvent()
+  recursively. So the flag needs to be a counter.
+
+Reviewed-by: Adam Jackson <ajax@redhat.com>
+--- a/include/X11/Xlibint.h
++++ b/include/X11/Xlibint.h
+@@ -207,7 +207,7 @@ struct _XDisplay
+ 
+ 	XIOErrorExitHandler exit_handler;
+ 	void *exit_handler_data;
+-        Bool in_ifevent;
++        CARD32 in_ifevent;
+ };
+ 
+ #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
+--- a/src/ChkIfEv.c
++++ b/src/ChkIfEv.c
+@@ -49,8 +49,8 @@ Bool XCheckIfEvent (
+ 	unsigned long qe_serial = 0;
+ 	int n;			/* time through count */
+ 
++        dpy->in_ifevent++;
+         LockDisplay(dpy);
+-        dpy->in_ifevent = True;
+ 	prev = NULL;
+ 	for (n = 3; --n >= 0;) {
+ 	    for (qelt = prev ? prev->next : dpy->head;
+@@ -80,7 +80,7 @@ Bool XCheckIfEvent (
+ 		/* another thread has snatched this event */
+ 		prev = NULL;
+ 	}
+-        dpy->in_ifevent = False;
++        dpy->in_ifevent--;
+ 	UnlockDisplay(dpy);
+ 	return False;
+ }
+--- a/src/IfEvent.c
++++ b/src/IfEvent.c
+@@ -48,8 +48,8 @@ XIfEvent (
+ 	register _XQEvent *qelt, *prev;
+ 	unsigned long qe_serial = 0;
+ 
++        dpy->in_ifevent++;
+         LockDisplay(dpy);
+-        dpy->in_ifevent = True;
+ 	prev = NULL;
+ 	while (1) {
+ 	    for (qelt = prev ? prev->next : dpy->head;
+@@ -60,7 +60,7 @@ XIfEvent (
+ 		    *event = qelt->event;
+ 		    _XDeq(dpy, prev, qelt);
+ 		    _XStoreEventCookie(dpy, event);
+-                    dpy->in_ifevent = False;
++                    dpy->in_ifevent--;
+ 		    UnlockDisplay(dpy);
+ 		    return 0;
+ 		}
+--- a/src/OpenDis.c
++++ b/src/OpenDis.c
+@@ -189,7 +189,7 @@ XOpenDisplay (
+ 	dpy->xcmisc_opcode	= 0;
+ 	dpy->xkb_info		= NULL;
+ 	dpy->exit_handler_data	= NULL;
+-        dpy->in_ifevent         = False;
++        dpy->in_ifevent         = 0;
+ 
+ /*
+  * Setup other information in this display structure.
+--- a/src/PeekIfEv.c
++++ b/src/PeekIfEv.c
+@@ -49,8 +49,8 @@ XPeekIfEvent (
+ 	register _XQEvent *prev, *qelt;
+ 	unsigned long qe_serial = 0;
+ 
++        dpy->in_ifevent++;
+ 	LockDisplay(dpy);
+-        dpy->in_ifevent = True;
+ 	prev = NULL;
+ 	while (1) {
+ 	    for (qelt = prev ? prev->next : dpy->head;
+@@ -64,7 +64,7 @@ XPeekIfEvent (
+ 			_XStoreEventCookie(dpy, &copy);
+ 			*event = copy;
+ 		    }
+-                    dpy->in_ifevent = False;
++                    dpy->in_ifevent--;
+ 		    UnlockDisplay(dpy);
+ 		    return 0;
+ 		}
+--- a/src/locking.c
++++ b/src/locking.c
+@@ -465,17 +465,33 @@ static void _XIfEventLockDisplay(
+     /* assert(dpy->in_ifevent); */
+ }
+ 
++static void _XInternalLockDisplay(
++    Display *dpy,
++    Bool wskip
++    XTHREADS_FILE_LINE_ARGS
++    );
++
++static void _XIfEventInternalLockDisplay(
++    Display *dpy,
++    Bool wskip
++    XTHREADS_FILE_LINE_ARGS
++    )
++{
++    /* assert(dpy->in_ifevent); */
++}
++
+ static void _XIfEventUnlockDisplay(
+     Display *dpy
+     XTHREADS_FILE_LINE_ARGS
+     )
+ {
+-    if (dpy->in_ifevent)
++    if (dpy->in_ifevent == 0) {
++        dpy->lock_fns->lock_display = _XLockDisplay;
++        dpy->lock_fns->unlock_display = _XUnlockDisplay;
++        dpy->lock->internal_lock_display = _XInternalLockDisplay;
++        UnlockDisplay(dpy);
++    } else
+         return;
+-
+-    dpy->lock_fns->lock_display = _XLockDisplay;
+-    dpy->lock_fns->unlock_display = _XUnlockDisplay;
+-    UnlockDisplay(dpy);
+ }
+ 
+ static void _XLockDisplay(
+@@ -507,6 +523,7 @@ static void _XLockDisplay(
+     if (dpy->in_ifevent) {
+         dpy->lock_fns->lock_display = _XIfEventLockDisplay;
+         dpy->lock_fns->unlock_display = _XIfEventUnlockDisplay;
++        dpy->lock->internal_lock_display = _XIfEventInternalLockDisplay;
+     }
+ }
+ 
+GitLab

diff --git a/x11-libs/libX11/libX11-1.8.2-r1.ebuild b/x11-libs/libX11/libX11-1.8.2-r1.ebuild
new file mode 100644
index 000000000000..b848ddf9b842
--- /dev/null
+++ b/x11-libs/libX11/libX11-1.8.2-r1.ebuild
@@ -0,0 +1,48 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+XORG_DOC=doc
+XORG_MULTILIB=yes
+XORG_TARBALL_SUFFIX=xz
+inherit toolchain-funcs xorg-3
+
+# Note: please bump this with x11-misc/compose-tables
+DESCRIPTION="X.Org X11 library"
+
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	>=x11-libs/libxcb-1.11.1[${MULTILIB_USEDEP}]
+	x11-misc/compose-tables
+
+	!<xfce-base/xfce4-settings-4.16.3
+"
+DEPEND="${RDEPEND}
+	x11-base/xorg-proto
+	x11-libs/xtrans
+"
+BDEPEND="test? ( dev-lang/perl )"
+
+PATCHES=(
+	"${FILESDIR}"/${P}-reentrancy.patch
+)
+
+src_configure() {
+	local XORG_CONFIGURE_OPTIONS=(
+		$(use_with doc xmlto)
+		$(use_enable doc specs)
+		--enable-ipv6
+		--without-fop
+		CPP="$(tc-getPROG CPP cpp)"
+	)
+	xorg-3_src_configure
+}
+
+src_install() {
+	xorg-3_src_install
+	rm -rf "${ED}"/usr/share/X11/locale || die
+}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: x11-libs/libX11/files/, x11-libs/libX11/
@ 2023-01-17  1:53 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2023-01-17  1:53 UTC (permalink / raw
  To: gentoo-commits

commit:     4984fd11b13e48ab6f7c569759c8e40e1dc2281e
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 17 01:47:27 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 17 01:47:27 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4984fd11

x11-libs/libX11: backport 2 regression fixes from master

Should fix bug #886349 but not really clear wrt bug #887593.

Bug: https://bugs.gentoo.org/886349
Bug: https://bugs.gentoo.org/887593
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/libX11-1.8.3-reentrancy-again.patch      | 188 +++++++++++++++++++++
 .../files/libX11-1.8.3-revert-XPutBackEvent.patch  |  57 +++++++
 x11-libs/libX11/libX11-1.8.3-r1.ebuild             |  49 ++++++
 3 files changed, 294 insertions(+)

diff --git a/x11-libs/libX11/files/libX11-1.8.3-reentrancy-again.patch b/x11-libs/libX11/files/libX11-1.8.3-reentrancy-again.patch
new file mode 100644
index 000000000000..3ab9b6b1424c
--- /dev/null
+++ b/x11-libs/libX11/files/libX11-1.8.3-reentrancy-again.patch
@@ -0,0 +1,188 @@
+https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/eb1c272ab5230d548077b9f59aca4b3457c3a8f8
+
+From eb1c272ab5230d548077b9f59aca4b3457c3a8f8 Mon Sep 17 00:00:00 2001
+From: GaryOderNichts <garyodernichts@gmail.com>
+Date: Sat, 17 Dec 2022 16:28:40 +0100
+Subject: [PATCH] Fix a9e845 and 797755 Allow X*IfEvent() to reenter libX11
+
+--- a/include/X11/Xlibint.h
++++ b/include/X11/Xlibint.h
+@@ -43,6 +43,10 @@ from The Open Group.
+ #include <X11/Xproto.h>		/* to declare xEvent */
+ #include <X11/XlibConf.h>	/* for configured options like XTHREADS */
+ 
++#ifdef XTHREADS
++#include <X11/Xthreads.h>
++#endif
++
+ /* The Xlib structs are full of implicit padding to properly align members.
+    We can't clean that up without breaking ABI, so tell clang not to bother
+    complaining about it. */
+@@ -207,7 +211,10 @@ struct _XDisplay
+ 
+ 	XIOErrorExitHandler exit_handler;
+ 	void *exit_handler_data;
+-        CARD32 in_ifevent;
++	CARD32 in_ifevent;
++#ifdef XTHREADS
++	xthread_t ifevent_thread;
++#endif
+ };
+ 
+ #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
+--- a/src/ChkIfEv.c
++++ b/src/ChkIfEv.c
+@@ -49,8 +49,11 @@ Bool XCheckIfEvent (
+ 	unsigned long qe_serial = 0;
+ 	int n;			/* time through count */
+ 
+-	dpy->in_ifevent++;
+ 	LockDisplay(dpy);
++#ifdef XTHREADS
++	dpy->ifevent_thread = xthread_self();
++#endif
++	dpy->in_ifevent++;
+ 	prev = NULL;
+ 	for (n = 3; --n >= 0;) {
+ 	    for (qelt = prev ? prev->next : dpy->head;
+--- a/src/IfEvent.c
++++ b/src/IfEvent.c
+@@ -48,8 +48,11 @@ XIfEvent (
+ 	register _XQEvent *qelt, *prev;
+ 	unsigned long qe_serial = 0;
+ 
+-	dpy->in_ifevent++;
+ 	LockDisplay(dpy);
++#ifdef XTHREADS
++	dpy->ifevent_thread = xthread_self();
++#endif
++	dpy->in_ifevent++;
+ 	prev = NULL;
+ 	while (1) {
+ 	    for (qelt = prev ? prev->next : dpy->head;
+--- a/src/PeekIfEv.c
++++ b/src/PeekIfEv.c
+@@ -49,8 +49,11 @@ XPeekIfEvent (
+ 	register _XQEvent *prev, *qelt;
+ 	unsigned long qe_serial = 0;
+ 
+-	dpy->in_ifevent++;
+ 	LockDisplay(dpy);
++#ifdef XTHREADS
++	dpy->ifevent_thread = xthread_self();
++#endif
++	dpy->in_ifevent++;
+ 	prev = NULL;
+ 	while (1) {
+ 	    for (qelt = prev ? prev->next : dpy->head;
+--- a/src/locking.c
++++ b/src/locking.c
+@@ -240,7 +240,9 @@ static void _XUnlockDisplay(
+     if (lock_hist_loc >= LOCK_HIST_SIZE)
+ 	lock_hist_loc = 0;
+ #endif /* XTHREADS_WARN */
+-    xmutex_unlock(dpy->lock->mutex);
++
++    if (dpy->in_ifevent == 0 || !xthread_equal(dpy->ifevent_thread, xthread_self()))
++        xmutex_unlock(dpy->lock->mutex);
+ }
+ 
+ 
+@@ -453,63 +455,24 @@ static void _XDisplayLockWait(
+ }
+ 
+ static void _XLockDisplay(
+-    Display *dpy
+-    XTHREADS_FILE_LINE_ARGS
+-    );
+-
+-static void _XIfEventLockDisplay(
+     Display *dpy
+     XTHREADS_FILE_LINE_ARGS
+     )
+ {
+-    /* assert(dpy->in_ifevent); */
+-}
++    struct _XErrorThreadInfo *ti;
+ 
+-static void _XInternalLockDisplay(
+-    Display *dpy,
+-    Bool wskip
+-    XTHREADS_FILE_LINE_ARGS
+-    );
++    if (dpy->in_ifevent && xthread_equal(dpy->ifevent_thread, xthread_self()))
++        return;
+ 
+-static void _XIfEventInternalLockDisplay(
+-    Display *dpy,
+-    Bool wskip
+-    XTHREADS_FILE_LINE_ARGS
+-    )
+-{
+-    /* assert(dpy->in_ifevent); */
+-}
+-
+-static void _XIfEventUnlockDisplay(
+-    Display *dpy
+-    XTHREADS_FILE_LINE_ARGS
+-    )
+-{
+-    if (dpy->in_ifevent == 0) {
+-	dpy->lock_fns->lock_display = _XLockDisplay;
+-	dpy->lock_fns->unlock_display = _XUnlockDisplay;
+-	dpy->lock->internal_lock_display = _XInternalLockDisplay;
+-	UnlockDisplay(dpy);
+-    } else
+-	return;
+-}
+-
+-static void _XLockDisplay(
+-    Display *dpy
+-    XTHREADS_FILE_LINE_ARGS
+-    )
+-{
+-#ifdef XTHREADS
+-    struct _XErrorThreadInfo *ti;
+-#endif
+ #ifdef XTHREADS_WARN
+     _XLockDisplayWarn(dpy, file, line);
+ #else
+     xmutex_lock(dpy->lock->mutex);
+ #endif
++
+     if (dpy->lock->locking_level > 0)
+-	_XDisplayLockWait(dpy);
+-#ifdef XTHREADS
++    _XDisplayLockWait(dpy);
++
+     /*
+      * Skip the two function calls below which may generate requests
+      * when LockDisplay is called from within _XError.
+@@ -517,14 +480,9 @@ static void _XLockDisplay(
+     for (ti = dpy->error_threads; ti; ti = ti->next)
+ 	    if (ti->error_thread == xthread_self())
+ 		    return;
+-#endif
++
+     _XIDHandler(dpy);
+     _XSeqSyncFunction(dpy);
+-    if (dpy->in_ifevent) {
+-	dpy->lock_fns->lock_display = _XIfEventLockDisplay;
+-	dpy->lock_fns->unlock_display = _XIfEventUnlockDisplay;
+-	dpy->lock->internal_lock_display = _XIfEventInternalLockDisplay;
+-    }
+ }
+ 
+ /*
+@@ -537,6 +495,9 @@ static void _XInternalLockDisplay(
+     XTHREADS_FILE_LINE_ARGS
+     )
+ {
++    if (dpy->in_ifevent && xthread_equal(dpy->ifevent_thread, xthread_self()))
++        return;
++
+ #ifdef XTHREADS_WARN
+     _XLockDisplayWarn(dpy, file, line);
+ #else
+-- 
+GitLab

diff --git a/x11-libs/libX11/files/libX11-1.8.3-revert-XPutBackEvent.patch b/x11-libs/libX11/files/libX11-1.8.3-revert-XPutBackEvent.patch
new file mode 100644
index 000000000000..b210defcf664
--- /dev/null
+++ b/x11-libs/libX11/files/libX11-1.8.3-revert-XPutBackEvent.patch
@@ -0,0 +1,57 @@
+https://bugs.gentoo.org/886349
+https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/176
+https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/174
+https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/88399e01be679bfcc9a5e8922ffe2c47f0e56dee
+
+From 88399e01be679bfcc9a5e8922ffe2c47f0e56dee Mon Sep 17 00:00:00 2001
+From: Yuxuan Shui <yshuiv7@gmail.com>
+Date: Tue, 3 Jan 2023 15:09:28 +0000
+Subject: [PATCH] Revert "Update XPutBackEvent() to support clients that put
+ back unpadded events"
+
+This reverts commit d6d6cba90215d323567fef13d6565756c9956f60.
+
+The reverted commit intended to fix the problem where an unpadded X
+event struct is passed into XPutBackEvent, by creating a padded struct
+with _XEventToWire and _XWireToEvent. However, _XWireToEvent updates the
+last sequence number in Display, which may cause xlib to complain about
+lost sequence numbers.
+
+IMO, the problem that commit tried to solve is a bug in the client
+library, and workaround it inside Xlib is bad practice, especially given
+the problem it caused. Plus, the offender cited in the original commit
+message, freeglut, has already fixed this problem.
+
+Fixes: #176 #174
+
+Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
+--- a/src/PutBEvent.c
++++ b/src/PutBEvent.c
+@@ -79,22 +79,9 @@ XPutBackEvent (
+     register XEvent *event)
+ 	{
+ 	int ret;
+-	xEvent wire = {0};
+-	XEvent lib = {0};
+-	Status (*fp)(Display *, XEvent *, xEvent *);
+-	int type = event->type & 0177;
+ 
+ 	LockDisplay(dpy);
+-	fp = dpy->wire_vec[type];
+-	if (fp == NULL)
+-		fp = _XEventToWire;
+-	ret = (*fp)(dpy, event, &wire);
+-	if (ret)
+-	{
+-		ret = (*dpy->event_vec[type])(dpy, &lib, &wire);
+-		if (ret)
+-			ret = _XPutBackEvent(dpy, &lib);
+-	}
++	ret = _XPutBackEvent(dpy, event);
+ 	UnlockDisplay(dpy);
+ 	return ret;
+ 	}
+-- 
+GitLab
+
+

diff --git a/x11-libs/libX11/libX11-1.8.3-r1.ebuild b/x11-libs/libX11/libX11-1.8.3-r1.ebuild
new file mode 100644
index 000000000000..a24f4cae12dd
--- /dev/null
+++ b/x11-libs/libX11/libX11-1.8.3-r1.ebuild
@@ -0,0 +1,49 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+XORG_DOC=doc
+XORG_MULTILIB=yes
+XORG_TARBALL_SUFFIX=xz
+inherit toolchain-funcs xorg-3
+
+# Note: please bump this with x11-misc/compose-tables
+DESCRIPTION="X.Org X11 library"
+
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	>=x11-libs/libxcb-1.11.1[${MULTILIB_USEDEP}]
+	x11-misc/compose-tables
+
+	!<xfce-base/xfce4-settings-4.16.3
+"
+DEPEND="${RDEPEND}
+	x11-base/xorg-proto
+	x11-libs/xtrans
+"
+BDEPEND="test? ( dev-lang/perl )"
+
+PATCHES=(
+	"${FILESDIR}"/${P}-revert-XPutBackEvent.patch
+	"${FILESDIR}"/${P}-reentrancy-again.patch
+)
+
+src_configure() {
+	local XORG_CONFIGURE_OPTIONS=(
+		$(use_with doc xmlto)
+		$(use_enable doc specs)
+		--enable-ipv6
+		--without-fop
+		CPP="$(tc-getPROG CPP cpp)"
+	)
+	xorg-3_src_configure
+}
+
+src_install() {
+	xorg-3_src_install
+	rm -rf "${ED}"/usr/share/X11/locale || die
+}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-17  1:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17  1:53 [gentoo-commits] repo/gentoo:master commit in: x11-libs/libX11/files/, x11-libs/libX11/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2022-11-25  6:05 Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox