feat(core): ask_timeout — bounded-wait request-reply (closes the ask liveness hole) - #6
Merged
Conversation
…liveness hole) ask blocks forever if an actor stores the Responder instead of replying. ask_timeout bounds the wait and returns Err(AskError::Timeout). The fast ask stays zero-alloc (stack cell); only the timeout path holds the cell in an Arc so a late reply after the timeout writes to live memory, not freed. A CONSUMED state + ReplyCell::Drop guard drop the orphaned value exactly once (no UAF, no double-drop, no leak). - Miri-verified: the late-reply/UAF/double-drop test and all ask tests pass under Miri (needed a #[cfg(miri)] no-op in pinning::pin_current_thread_to, since Miri can't emulate affinity/QoS syscalls — placement is a bench concern, irrelevant to correctness). - Reconciled onto current English main (this work had been stranded on an unmerged pre-English branch): ask.rs written in English, guides/README re-add ask_timeout (EN + JA), README known- limitations updated to reflect the bounded-wait escape hatch. Verified: build (default+net), tests (incl. 3 new timeout tests), doctests, Loom, Miri, clippy. Co-Authored-By: Claude Opus 4.8 <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.
askblocks forever if an actor stores theResponderinstead of replying — a real liveness hole a reviewer would poke at.ask_timeout(dur, ..)bounds the wait and returnsErr(AskError::Timeout).Design
askstays zero-alloc (reply cell on the caller's stack). Onlyask_timeoutholds the cell in anArc, so a late reply after the timeout writes to live memory instead of a freed stack frame.CONSUMEDstate +ReplyCell::Dropguard ensure the orphaned value (late reply, caller already gone) is dropped exactly once — no use-after-free, no double-drop, no leak.Verification
asktests pass under Miri, includingask_timeout_late_reply_is_dropped_without_uaf(drives the exact UAF/double-drop path). Required a#[cfg(miri)]no-op inpinning::pin_current_thread_to(Miri can't emulate affinity/QoS syscalls; placement is a benchmark concern, irrelevant to correctness).Docs (English + Japanese, parallel)
ask.rswritten in English;ask_timeoutre-added toguide.md/guide.ja.mdand both READMEs; the "ask liveness" known-limitation now points toask_timeoutas the bounded-wait escape hatch.Note: this reconciles work that had been stranded on an unmerged pre-English branch onto current English
main.🤖 Generated with Claude Code