fix(input): use CFUNCTYPE to avoid variadic ABI SIGSEGV in ei_seat_bind_capabilities - #32
Open
AgainPsychoX wants to merge 2 commits into
Open
fix(input): use CFUNCTYPE to avoid variadic ABI SIGSEGV in ei_seat_bind_capabilities#32AgainPsychoX wants to merge 2 commits into
AgainPsychoX wants to merge 2 commits into
Conversation
…_capabilities Raw ctypes variadic calls are ABI-fragile across Python/libffi versions. On Python 3.14 + libei 1.5.0 the wrong register/stack placement causes a SIGSEGV inside ei_seat_bind_capabilities. Building a fully-typed CFUNCTYPE for the exact argument list gives libffi explicit placement. Also fixes the sentinel: the loop terminates on `cap > 0`, so the terminator must be c_int(0), not c_void_p(None). Fixes isac322#29 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous commit used c_int(0); the public API documents the sentinel as NULL. Switch to c_void_p(None) to match the contract. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
session_connectcrashes with SIGSEGV insideei_seat_bind_capabilitieson Python 3.14 + libei 1.5.0 (reported in #29 for Fedora 43 / Bazzite).Root cause: the original code called
ei_seat_bind_capabilitiesas a raw ctypes variadic function. Raw variadic calls via ctypes/libffi are ABI-fragile — on Python 3.14 the register/stack placement is wrong, causing a crash inside the C function.A secondary bug: the sentinel was
c_void_p(None)(NULL pointer), but libei's loop terminator iswhile ((cap = va_arg(args, enum ei_device_capability)) > 0)— it checkscap > 0, not a pointer-NULL. The correct sentinel isc_int(0).Fix
Build a fully-typed
ctypes.CFUNCTYPEfor the exact argument list (seat pointer + N capability uints + int sentinel). This gives libffi explicit register/stack placement for every argument, eliminating the ABI ambiguity regardless of Python or libffi version.Testing
Tested on Manjaro (libei 1.4.x) via both the CLI (
uv run python -m kwin_mcp.cli) and live MCP session — no regression,session_connectsucceeds and input injection works correctly.Fixes #29