From 27180bc0fecf7d6219617fa5ebd2f909c0cd5562 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Mon, 17 Aug 2026 18:38:12 +0900 Subject: [PATCH] test: a key passed through is not committed text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Korean Enter commits the syllable and lets the key on, so xim.c sends the commit and then forwards the key. pumpinput took the text of either and kept the last, so under load the Return's own carriage return overwrote 가: 22 of 25 runs failed on a loaded machine and none on an idle one. An XIM commit arrives as XLookupChars; a forwarded key comes back as XLookupBoth, and is not a commit. Co-Authored-By: Claude Opus 5 (1M context) --- tests/xim_live_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/xim_live_test.c b/tests/xim_live_test.c index 5c100dc..f1a008d 100644 --- a/tests/xim_live_test.c +++ b/tests/xim_live_test.c @@ -129,10 +129,10 @@ pumpinput(Display *dpy, XIC ic, char *commit, size_t cap, int timeout) continue; n = Xutf8LookupString(ic, &ev.xkey, buf, sizeof buf - 1, &sym, &status); - if(n < 0 || ((status == XLookupChars || status == XLookupBoth) && + if(n < 0 || (status == XLookupChars && ((size_t)n >= cap || commit == NULL))) return 0; - if((status == XLookupChars || status == XLookupBoth) && n != 0){ + if(status == XLookupChars && n != 0){ memcpy(commit, buf, n); commit[n] = '\0'; } @@ -273,7 +273,7 @@ sendkey(Display *dpy, XIC ic, Window win, KeySym sym, unsigned int state, if(n < 0) return fail("Xutf8LookupString failed for keysym %#lx", (unsigned long)sym); - if((status == XLookupChars || status == XLookupBoth) && n != 0){ + if(status == XLookupChars && n != 0){ if((size_t)n >= cap) return fail("commit buffer overflow"); memcpy(commit, buf, n);