Skip to content

fix: segfault on Python 3.14 in libei variadic function call#7

Open
davidselassie wants to merge 2 commits intoisac322:mainfrom
davidselassie:fix/python-3.14-ctypes-argtypes
Open

fix: segfault on Python 3.14 in libei variadic function call#7
davidselassie wants to merge 2 commits intoisac322:mainfrom
davidselassie:fix/python-3.14-ctypes-argtypes

Conversation

@davidselassie
Copy link
Copy Markdown

@davidselassie davidselassie commented Apr 4, 2026

Summary

Set argtypes on ei_seat_bind_capabilities — a variadic C function
whose argtypes were intentionally left unset because ctypes historically
didn't require them. On Python 3.14 this causes a segfault (exit code
139) during session start, as ctypes misinterprets the variadic arguments
at the C ABI level without the fixed parameter declaration.

Motivation

uvx install kwin-mcp does not respect .python-version — it uses
whatever Python satisfies requires-python (>=3.12). Users on systems
with Python 3.14 as default (e.g. Fedora 43) hit this crash immediately
on session start. The fix sets argtypes to just the fixed parameter
(the seat pointer); the variadic arguments at the call site are already
wrapped as ctypes instances and pass through correctly.

How to Test

  1. uv python pin 3.14 && uv sync
  2. Revert the fix in src/kwin_mcp/input.py
  3. echo "session_start" | uv run python -m kwin_mcp.cli → exit code 139 (SIGSEGV)
  4. Restore the fix, re-run → session starts normally
  5. uv python pin 3.12 && uv sync to restore

Checklist

  • uv run ruff check . passes
  • uv run ruff format --check . passes
  • uv run ty check passes
  • CHANGELOG.md updated (if user-facing change)
  • README.md updated (if new tools or changed behavior)

davidselassie and others added 2 commits April 4, 2026 12:33
## Summary

Set `argtypes` on `ei_seat_bind_capabilities` — a variadic C function
whose argtypes were intentionally left unset because ctypes historically
didn't require them. On Python 3.14 this causes a segfault (exit code
139) during session start, as ctypes misinterprets the variadic arguments
at the C ABI level without the fixed parameter declaration.

## Motivation

`uvx install kwin-mcp` does not respect `.python-version` — it uses
whatever Python satisfies `requires-python` (>=3.12). Users on systems
with Python 3.14 as default (e.g. Fedora 43) hit this crash immediately
on session start. The fix sets `argtypes` to just the fixed parameter
(the seat pointer); the variadic arguments at the call site are already
wrapped as ctypes instances and pass through correctly.

## How to Test

1. `uv python pin 3.14 && uv sync`
2. Revert the fix in `src/kwin_mcp/input.py`
3. `echo "session_start" | uv run python -m kwin_mcp.cli` → exit code 139 (SIGSEGV)
4. Restore the fix, re-run → session starts normally
5. `uv python pin 3.12 && uv sync` to restore

## Checklist

- [x] `uv run ruff check .` passes
- [x] `uv run ruff format --check .` passes
- [x] `uv run ty check` passes
- [ ] CHANGELOG.md updated (if user-facing change)
- [ ] README.md updated (if new tools or changed behavior)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@davidselassie davidselassie changed the title Fix segfault on Python 3.14 in libei variadic function call fix: segfault on Python 3.14 in libei variadic function call Apr 4, 2026
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