Skip to content

Fix byte-based JSON-RPC framing and request-id race (Python client) - #5

Merged
wadoon merged 1 commit into
mainfrom
fix/python-rpc-correctness
Jun 22, 2026
Merged

Fix byte-based JSON-RPC framing and request-id race (Python client)#5
wadoon merged 1 commit into
mainfrom
fix/python-rpc-correctness

Conversation

@unp1

@unp1 unp1 commented Jun 22, 2026

Copy link
Copy Markdown
Member

The fix for that one is on #7, which need to be applied first

Fixes two correctness bugs in the Python client transport (keyext.client.python):

  • Framing was character-based, not byte-based. The Gson server sends raw multi-byte UTF-8, but recv_response read N characters from a text stream, truncating any message past the first non-ASCII glyph (common in KeY terms) and desyncing the stream. The transport now uses binary streams, frames on the UTF-8 byte length, and reads exactly Content-Length bytes (looping over short reads). NetKeY opens binary socket makefiles to match.
  • next_id was incremented without a lock, so concurrent call_method calls could share an id and have responses delivered to the wrong caller. Id allocation is now lock-guarded.

Adds tests/test_rpc.py (stdlib unittest): byte-counted framing, raw-UTF-8 reads (incl. back-to-back and partial reads), and concurrent id allocation. All green.

PR has been created with AI tooling

@unp1
unp1 force-pushed the fix/python-rpc-correctness branch from 35e5cbf to eee3187 Compare June 22, 2026 19:41
@wadoon
wadoon merged commit 2dae42d into main Jun 22, 2026
3 checks passed
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.

2 participants