Skip to content

[QEC] Decoding server: guard tx-slot writes, drop dead code from #769 - #779

Open
bmhowe23 wants to merge 1 commit into
NVIDIA:mainfrom
bmhowe23:decoding-server-inline-followups
Open

[QEC] Decoding server: guard tx-slot writes, drop dead code from #769#779
bmhowe23 wants to merge 1 commit into
NVIDIA:mainfrom
bmhowe23:decoding-server-inline-followups

Conversation

@bmhowe23

@bmhowe23 bmhowe23 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Post-merge cleanups on the HOST_CALL request path:

  • ResultWriter: split out payload_capacity(), which checks the slot against sizeof(RPCResponse) BEFORE subtracting. The old payload() evaluated capacity_ - sizeof(RPCResponse) first and relied on a later ||-term to catch the underflow.
  • handle_get_corrections: take the payload pointer and capacity from the ResultWriter instead of recomputing them. The hand-rolled slot_size - sizeof(RPCResponse) bypassed the very guard the writer exists to provide; a slot too short for the response header now yields nullptr -> INTERNAL_ERROR rather than a wrapped capacity.
  • Assert sizeof(RPCResponse) <= sizeof(RPCHeader). Every write_response caller gates on slot_size >= sizeof(RPCHeader) and then writes an RPCResponse into that slot; the structs are equal-sized today but live in the cudaq realtime headers and move independently of this repo.
  • Drop DecodingServer::print_session_stats(), orphaned when the stats loop was moved into cudaqx_qec_decoding_server_print_stats(). Two copies of the QEC_DECODING_SERVER_DECODER_STATS line the test harness greps for could drift apart.
  • Retire two CMake comments describing the removed worker threads.

New test RpcSlotWrite.ResultWriterRefusesASlotTooSmallForTheResponseHeader covers the exact-fit, undersized, null, and roomy slots.

…IA#769

Post-merge cleanups on the HOST_CALL request path:

- ResultWriter: split out payload_capacity(), which checks the slot
  against sizeof(RPCResponse) BEFORE subtracting.  The old payload()
  evaluated `capacity_ - sizeof(RPCResponse)` first and relied on a
  later ||-term to catch the underflow.
- handle_get_corrections: take the payload pointer and capacity from
  the ResultWriter instead of recomputing them.  The hand-rolled
  `slot_size - sizeof(RPCResponse)` bypassed the very guard the writer
  exists to provide; a slot too short for the response header now
  yields nullptr -> INTERNAL_ERROR rather than a wrapped capacity.
- Assert sizeof(RPCResponse) <= sizeof(RPCHeader).  Every write_response
  caller gates on `slot_size >= sizeof(RPCHeader)` and then writes an
  RPCResponse into that slot; the structs are equal-sized today but live
  in the cudaq realtime headers and move independently of this repo.
- Drop DecodingServer::print_session_stats(), orphaned when the stats
  loop was moved into cudaqx_qec_decoding_server_print_stats().  Two
  copies of the QEC_DECODING_SERVER_DECODER_STATS line the test harness
  greps for could drift apart.
- Retire two CMake comments describing the removed worker threads.

New test RpcSlotWrite.ResultWriterRefusesASlotTooSmallForTheResponseHeader
covers the exact-fit, undersized, null, and roomy slots.

Signed-off-by: Ben Howe <bhowe@nvidia.com>
@bmhowe23
bmhowe23 requested a review from cketcham2333 August 7, 2026 22:37
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