From 751fbc59c30604980fdd19cb4b333d3cf2eccb24 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 21 Jun 2024 14:37:24 +0200 Subject: [PATCH] Fix deadlock in XRebindKeysym() Xlib is now built with threading support enabled from the constructor by default. XRebindKeysym() acquires the display lock, then calls: | XRebindKeysym() | LockDisplay() | ComputeMaskFromKeytrans() | -> XkbKeysymToModifiers() | -> _XkbLoadDpy() | -> XkbGetMap() | -> XkbGetUpdatedMap() | LockDisplay() And the dead lock: | Xlib ERROR: XKBGetMap.c line 575 thread 1fc6e580: locking display already | locked at KeyBind.c line 937 To avoid the issue, call ComputeMaskFromKeytrans() from outside the display lock. Signed-off-by: Olivier Fourdan Closes: https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/216 Part-of: --- src/KeyBind.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/KeyBind.c b/src/KeyBind.c index a8181b91..a5e22131 100644 --- a/src/KeyBind.c +++ b/src/KeyBind.c @@ -958,8 +958,9 @@ XRebindKeysym ( memcpy ((char *) p->modifiers, (char *) mlist, (size_t) nb); p->key = keysym; p->mlen = nm; - ComputeMaskFromKeytrans(dpy, p); UnlockDisplay(dpy); + ComputeMaskFromKeytrans(dpy, p); + return 0; } -- 2.45.2