diff -urN libX11-1.8.13-orig/modules/im/ximcp/imCallbk.c libX11-1.8.13/modules/im/ximcp/imCallbk.c --- libX11-1.8.13-orig/modules/im/ximcp/imCallbk.c 2026-02-08 07:26:26 +0900 +++ libX11-1.8.13/modules/im/ximcp/imCallbk.c 2026-05-10 06:37:19 +0900 @@ -204,6 +204,9 @@ */ _XimProcessPendingCallbacks(ic); + // XDestroyIC() deadlock workaround + if (major_opcode == XIM_DESTROY_IC_REPLY) ic->destroyed = True; + /* check if the protocol should be processed here */ if (major_opcode > 82) { diff -urN libX11-1.8.13-orig/modules/im/ximcp/imDefIc.c libX11-1.8.13/modules/im/ximcp/imDefIc.c --- libX11-1.8.13-orig/modules/im/ximcp/imDefIc.c 2026-02-08 07:26:26 +0900 +++ libX11-1.8.13/modules/im/ximcp/imDefIc.c 2026-05-10 06:35:27 +0900 @@ -823,6 +823,8 @@ XICID icid = buf_s[1]; Bool ret = False; + if (ic->destroyed) return True; // deadlock workaround + if ((major_opcode == XIM_DESTROY_IC_REPLY) && (minor_opcode == 0) && (imid == im->private.proto.imid) @@ -902,6 +904,8 @@ int ret_code; if (IS_SERVER_CONNECTED(im)) { + ic->destroyed = False; // deadlock workaround + buf_s[0] = im->private.proto.imid; /* imid */ buf_s[1] = ic->private.proto.icid; /* icid */ diff -urN libX11-1.8.13-orig/modules/im/ximcp/imTransR.c libX11-1.8.13/modules/im/ximcp/imTransR.c --- libX11-1.8.13-orig/modules/im/ximcp/imTransR.c 2026-02-08 07:26:26 +0900 +++ libX11-1.8.13/modules/im/ximcp/imTransR.c 2026-05-10 06:37:14 +0900 @@ -238,8 +238,10 @@ } if ((*predicate)(im, read_len, buf, arg)) break; - if (_XimCallDispatcher(im, read_len, buf)) + if (_XimCallDispatcher(im, read_len, buf)) { + if ((*predicate)(im, read_len, buf, arg)) break; // XDestroyIC() deadlock workaround continue; + } _XimError(im, 0, XIM_BadProtocol, (INT16)0, (CARD16)0, (char *)NULL); } *len = read_len; diff -urN libX11-1.8.13-orig/src/xlibi18n/Ximint.h libX11-1.8.13/src/xlibi18n/Ximint.h --- libX11-1.8.13-orig/src/xlibi18n/Ximint.h 2026-02-08 07:26:26 +0900 +++ libX11-1.8.13/src/xlibi18n/Ximint.h 2026-05-10 06:37:10 +0900 @@ -91,6 +91,7 @@ XICMethods methods; XICCoreRec core; XICPrivateRec private; + Bool destroyed; // XDestroyIC() deadlock workaround } XicRec; typedef struct _XimDefIMValues {