Skip to content

Xi: swap DevicePropertyNotify events for byte-swapped clients - #4024

Open
ztancrell wants to merge 1 commit into
X11Libre:masterfrom
ztancrell:xi-swap-device-property-notify
Open

ztancrell wants to merge 1 commit into
X11Libre:masterfrom
ztancrell:xi-swap-device-property-notify

Conversation

@ztancrell

@ztancrell ztancrell commented Oct 19, 2026 •

Copy link
Copy Markdown

XInputExtensionInit() sets SEventIDispatch as the swap handler in EventSwapVector for the other XI 1.x events. DevicePropertyNotify was missed, so its slot still holds NotImplemented. SEventIDispatch already handles this event (SDevicePropertyNotifyEvent), and IResetProc() already resets the slot.

How it crashes: a byte-swapped client selects DevicePropertyNotifyMask, then a device property changes. WriteEventsToClient() calls NotImplemented(), which calls FatalError("Not implemented") and kills the server for every session. Any opposite-endian client can trigger this.

The fix is one line, registering SEventIDispatch for DevicePropertyNotify like the neighbouring events.

Test: this PR adds a pyxtest regression test, TestXIDevicePropertyNotifySwap, and an XSelectExtensionEvent request builder in proto/xi.py. The test has a byte-swapped client select DevicePropertyNotify and change a property on the virtual core keyboard, then checks that the server is still alive.

Results on Xvfb, built from current master:

  • Without the fix, the test fails because the server dies.
  • With the fix, it passes.
  • Full test/pyxtest/ with the fix: 37 passed, 26 skipped, 0 failed.

AI disclosure: I wrote this patch with AI help (Claude Code, Claude Opus 4.8 and Claude Opus 5.5). The commit has Co-Authored-By lines for both models. I reviewed the change and ran the tests above myself before submitting.

🤖 Generated with Claude Code

@ztancrell
ztancrell force-pushed the xi-swap-device-property-notify branch 2 times, most recently from 2205a1c to a46a35d Compare October 19, 2026 02:39
XInputExtensionInit() registers SEventIDispatch in EventSwapVector for
the other XI 1.x events, but not for DevicePropertyNotify, which keeps
the NotImplemented default. SEventIDispatch already handles the event
(SDevicePropertyNotifyEvent), and IResetProc already resets the slot.

So when a byte-swapped client selects DevicePropertyNotifyMask and a
device property changes, WriteEventsToClient() calls NotImplemented(),
which calls FatalError() and takes the server down. Register
SEventIDispatch for it like the others.

Add a pyxtest regression test: a byte-swapped client selects
DevicePropertyNotify via XSelectExtensionEvent, changes a device
property, and must receive the event with its atom byte-swapped. On
Xvfb the test fails without this change and passes with it.

This patch was written with AI assistance (Claude Code, Claude Opus
4.8 and Claude Opus 5.5). I reviewed the change and ran the test
before submitting.

Signed-off-by: ztancrell <ztancrell@tutamail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ztancrell
ztancrell force-pushed the xi-swap-device-property-notify branch from a46a35d to d38800b Compare October 29, 2026 16:20
@metux
metux force-pushed the master branch 4 times, most recently from eae2c21 to 483a172 Compare October 30, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant