Case file — PR #609: fix(selene): preserve DMA, RDMA, and shared-region lifetimes across cancel, close, and scatter
Author: yatesdr (COLLABORATOR; body says "Discord: D-Rock"). Branch fix/selene-dma-lifetime-safety → main, base 5df8edd3 (the merge of #607), single commit 304dd3a. Merged 2026-11-29 17:27, 19 minutes after opening, with 0 reviews, 0 comments, no labels, and CI failed on the head commit per the orientation packet. 15 files, +225/−71 (selene/src 12 files +154/−48; selene-manager/src 3 files +71/−23).
Key findings
- Landed unreviewed, on a red head commit. Opened 17:08 and merged 17:27 the same day by its own author's account flow; no review, no labels, no autobot case file on this PR (contrast the sibling #607, which got a full autobot "Ready To Merge" review). The packet records CI as failed on 304dd3a; which job failed could not be identified from here (see Open questions). — [#609 metadata; note #4].
- Its hardware evidence is not its own. The entire "Combined 4-PR validation & SM120/SM121 hardware qualification" block was run on the stack of #609+#610+#611+#612 before the rebase, and the body concedes only CPU tests were re-run afterwards. The same block, including the same limitation sentence, appears verbatim in #610, #611 and #612 — one qualification run cited four times. The named CUDA suite is
helios::offload::, and this PR does not touch helios. — note #3, note #5. - "Zero latency or parity regression" carries no numbers. The only quantitative statement is "bit-exact
pos0parity"; there is no latency or throughput figure anywhere in the PR. — note #3. - The diff does more than the description says. (a)
SliceLayout::newgains checked arithmetic with two new error strings — same overflow-hardening class as #612's work, never mentioned. (b) An existing #497-era regression assertion inselene/src/offload/tests.rsis relaxed, deleting thefail == Some(1)case that proved memory is not closed when disk close fails, so that short-circuit can no longer be caught by that test. (c)Engine::quarantinegoes from private topub(crate). (d)rdma::Device::openloses itsunsafemarker and changes signature toArc<Region>(bothpub(crate)). — note #2. - Operator-visible behaviour changes the description does not spell out.
MemoryStore::closecan now return a new error:"host KV compression did not finish before close"(selene/src/memory.rs:3113-3115);CompositeStore::closenow runs both closes and returnsdisk.and(memory)(selene/src/composite.rs:1619-1626), so a memory error can surface where previously only the disk error could; andconn::shutdownon its timeout path now callsengine.quarantine()(selene/src/pool/conn.rs:216-223), whichmem::forgets session regions, SHM attachment regions and staging for the life of the process (selene/src/pool/engine/mod.rs:549-573; selene/src/pool/agent.rs:1729-1737). No doc mentions the widened retention. — note #11, note #15. - No linked issue, crash report or reproduction backs the "why". The defects are self-asserted from an apparent one-day audit that also produced #610/#611/#612, all opened in the same minute. The closest independent confirmation that this area had real aliasing/UAF bugs is #607 (merged 10 minutes earlier, and reviewed), which fixed staging-slot double release and peer-DMA-gated window release. — note #7.
- Two of the fixes are "never free it". On failure paths the PR leaks rather than frees:
core.pool.leak()(memory.rs:3104-3106),mem::forget(compressor)(memory.rs:3111),mem::forget(regions)in both quarantine paths, plus the pre-existingmem::forget(staging). This matches the existing quarantine idiom ("keep every pin, mapping and registration for the life of the process"), but #609 extends it to two objects previously freed. — note #10. - The Windows
#[cfg(windows)]IOCP attach is the one unexercised build path (selene/src/disk.rs,ReadAhead::start), and the description admits it was never compiled or run on Windows — while sibling PRs #496/#497 reported Windows IOCP test runs. Windows selene tests are part of CI (.github/workflows/native-serving.yml:53-55(not opened)), so a break here would surface in later PRs, not this one. — note #3, note #6, note #15.
The change
Verified hunk by hunk against the diff (note #1):
- selene/src/memory.rs (+33/−10).
MemoryStore's fields are reordered sotransfers: SharedCopieris declared beforecore: Core(memory.rs:2243-2245) — in Rust that is Drop order, so copy threads now stop before the slab core unmaps the pinned slabs the CUDA copier may still DMA into.AsyncCompressor::pump_spawnsgets a localstruct ActiveGuardwith aDropthat decrements the active counter and notifies at zero (memory.rs:2024-2038), replacing a manual decrement, so a panic inencode_host_taskcan no longer leak the counter and hangAsyncCompressor::drop's condvar wait.MemoryStore::close(memory.rs:3074-3120) now computescompressor_busy, closes the copier, leaks the pool if either the copier close failed or the compressor is still busy, and returnsErr("host KV compression did not finish before close")after forgetting the compressor. - selene/src/disk_store.rs (+2/−2). Same Drop-order fix in
Resources:transfersbeforepool: Option<SlabPool>. That is the whole change. - selene/src/composite.rs (+3/−3).
CompositeStore::closeno longer short-circuits: it calls bothself.disk.close()andself.memory.close(), clears state, then returnsdisk.and(memory)(composite.rs:1619-1626). - selene/src/pool/engine/mod.rs (+7/−1).
Engine::quarantinebecomespub(crate)and, in addition to forgettingdrainingandnet, now forgetssess.regionsandAttachment::Shm{regions,..}(mod.rs:549-573). - selene/src/pool/conn.rs (+1).
shutdownquarantines on the timeout path before returning "the pool could not drain its transfers at close" (conn.rs:216-223). - selene/src/pool/agent.rs (+3).
Agent::quarantinenow also forgetsself.shared's regions (agent.rs:1732-1734). - selene/src/pool/net.rs (+3/−7), selene/src/pool/rdma.rs (+9/−13).
Staging.regionbecomesArc<Region>;rdma::Deviceholds_region: Arc<Region>(rdma.rs:31-37) dropped only afteribv_dereg_mr(rdma.rs:66-71), andopenbecomes a safefntakingArc<Region>(rdma.rs:44-63; absent-module stub follows at rdma.rs:121-127). BecausePair::dropforgets aDevicewhose close failed (rdma.rs:107), the registration can now outlive the staging block by construction instead of by field order. - selene/src/shared/slice.rs (+68/−2).
SliceLayout::newuseschecked_addfor the cumulative page/row record sizes with new errors "page record size overflow"/"row record size overflow"; newunsafe fn scatter_disjoint(rank, window: *mut u8, window_len, pages, row, packed)validates viacheckandptr::copy_nonoverlappings only that rank's slices (slice.rs:214-248); new testscatter_disjoint_matches_gather_across_ranks(slice.rs:446-462). - selene-manager/src/regions.rs (+58/−8). Bounds checking factored into
range(); newunsafe fn bytes_read(&self, ..) -> io::Result<&'a [u8]>(regions.rs:47-56) and safeptr_mutreturning(*mut u8, usize)(regions.rs:59-66); new testbytes_read_allows_overlapping_shared_views(regions.rs:132-146) plus negative bounds asserts (regions.rs:127-128). - selene-manager/src/data/channel.rs (+12/−14), pool/pass.rs (+1/−1). Three send-side
bytescalls becomebytes_read(channel.rs:736-741, 780-797);pass::runlikewise (pass.rs:171-175); the receive-side rank scatter replacesbytes+layout.scatterwithptr_mut+unsafe scatter_disjoint(channel.rs:934-942). - Tests. New
mid_session_quarantine_retains_active_session_and_attachment_regions(selene/src/pool/engine/tests.rs:1571-1589);selene/src/offload/tests.rsassertion relaxed (offload/tests.rs:659 on main).
Description/diff mismatches are in Key findings 4–5; the user-visible close error is the one that reaches operators.
The why
The stated problem has four strands: (1) slab pools unmapped before transfer/compression threads were joined and CompositeStore::close skipping memory.close() when disk.close() failed; (2) quarantine dropping mapped shared/session regions while an un-drained peer or copier still referenced them, and rdma::Device not retaining the staging region of a quarantined QP; (3) overlapping &mut [u8] from LocalRegions across concurrent readers and multi-rank scatter — undefined behaviour in Rust; (4) a Windows overlapped handle not attached to its IOCP queue.
No issue, report, crash dump or reproduction is linked; the body references only #496, #497 and #607. Of the four strands, the CompositeStore::close short-circuit and the IOCP attach are plainly visible as unconditional defects in the code; the quarantine strand depends on a timeout path (CLOSE_TIMEOUT) actually firing; the aliasing strand depends on two data-channel handlers overlapping, which I verified is reachable: each accepted data connection is its own task (selene-manager/src/data/channel.rs:435-447) and all handlers share one Arc<LocalRegions> (channel.rs:230, 1033), so two rank windows of the same put can concurrently form &mut views over overlapping bytes (note #14).
Context that does exist: #607, merged ten minutes earlier and reviewed, fixed the reported staging-slot double release that enabled "concurrent &mut [u8] aliasing" and released windows while a peer rank still had in-flight DMA. #609 generalises that theme to quarantine, RDMA staging and the manager's scatter. There is no evidence any of these defects were hit in the field. — note #7.
Related work
- The batch. #609/#610/#611/#612 were all opened at 17:08 by yatesdr and merged 17:27–17:32 in that order; all four say "Discord: D-Rock" and share the identical hardware-evidence block. #607 and #609 mutually reference each other, and #607's autobot review states the four companions were already rebased onto #607. — note #5.
- #607 "selene,selene-manager,helios: fix pool staging UAF, chain walk DoS, multi-process put corruption, and offload lifecycle bugs" (lukealonso, merged 17:17, +1211/−41): #609's base commit is its merge (5df8edd3). #609 builds directly on it. — note #5, note #9.
- #611 (merged 17:32, +260/−43) touches 5 of the same files and edits the same functions one commit later —
Agent::quarantine(addsjobs.clear()/pending.clear()) andconn::shutdown. So #609's quarantine hunks are not the final shape on main; the two are complementary, and main's quarantine path is #609+#611 combined. — note #5, note #9. - #610 (merged 17:28, +597/−158) rewrites the same store/teardown files (#memory.rs, composite.rs, disk.rs, disk_store.rs) with the same "retain until drained" theme (
Sharded::close,Peer::shutdown). Overlapping in intent, no hunk conflict found. — note #5. - #612 (merged 17:32) rejects multi-process (
world >= 2) packedPutBegin/PinAckgrants, pruning part of the multi-rank surface #609 made alias-free; it also lands the same class of checked-arithmetic hardening. Autobot's review of #612 was "Review Stopped — already fixed another way / no longer needed". — note #5, note #14. - #497 (FujitsuPolycom, merged) owns
disk_and_memory_share_one_registration_with_independent_copiers_and_safe_close, the exact test #609 relaxes; #497 reported running "6 Windows IOCP tests", and #496 reported 13 — the contrast for #609's unverified Windows change. — note #6. - #504 (yatesdr, merged) introduced
AsyncCompressorand thecompressorfield #609 hardens. #380 (yatesdr) owns the RDMA staging registration #609 re-plumbs; commit c7ee0780 (2026-11-18) is the last touch of selene/src/pool/rdma.rs before #609. #92 (yatesdr) is the origin of the pool, data channel andLocalRegions. — note #6. - Long single-author lineage on the same files (#141, #168, #413, #415, #429, #524, #610, #612); #609 is the newest entry. Not relevant: #255 (open issue, prefix-cache capacity_rejected — eviction, not lifetimes), #477 (closed, superseded by #504), #554 (open draft Engram RDMA READ — touches rdma.rs, so textual-conflict risk only). — note #6, note #13.
Recent activity
The same day, immediately before #609: 5df8edd3 (#607, the base), f7256584 (#496) and dad2fa56 (#497) (PCCessna's disk-fetch work), 716df00f (#504, 2026-11-25, AsyncCompressor), and ad72c493 (require pool attachment at startup / register off the I/O thread — the "first connect decides" attachment contract in conn.rs:590-675 that Engine::quarantine now unwinds). After #609: 8d05b9b6 (#611), a56333a0 (#610), 3801ff1b (#612). Nothing in the touched files was reverted or reversed; #609 sits in the middle of a same-day pile-up and is neither undone nor undoing. — note #9.
People
yatesdr is a COLLABORATOR with 79 merged PRs in 180 days and is the dominant committer in the touched areas — 36 commits in selene/src and 30 in selene-manager/src over 180 days, versus Luke Alonso 5/3 and Martin Vit 2. Their areas of record: helios/src (34), docs (33), selene/src (32), selene-manager/src (25), selene-manager/tests (20). The charter's named priority contributors are @voipmonitor, @original-el8, @lukealonso — yatesdr is not among them, but is effectively the owner of this code.
Who else works here: Luke Alonso (@lukealonso, priority contributor) authored #607, the PR this stacks on, and touched agent.rs/net.rs/engine/tests.rs (not opened); PCCessna (FujitsuPolycom) authored #496/#497 and owns the offload test #609 modifies.
Engagement on #609 itself: none. 0 comments, 0 reviews, no reactions, no labels. The only cross-PR attention is #607's autobot review naming #609 as a companion. — note #8.
Community
Nothing found beyond the above: no comments, reviews, reactions or cross-links on #609 other than the #607 mention. — notes #4, #8.
Project fit
Lines up: the Goals line "Store prefix-cache checkpoints in host memory and share them across Flare instances via Selene." (charter line 24) is precisely the path this hardens; "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)" is honoured in spirit — leaks are deliberate ownership retention, not swallowed errors; "No per-model special cases or flags" (line 43) is satisfied — no flags, no model branches, no wire-protocol change (selene.proto (not opened) untouched); "Be explicit and pin everything (#215)" is neutral — no dependency changes.
Where it strains: (a) "Solve the right problem in the right place … look for the smallest footprint in shared code" (line 9) — the fix is spread across 15 files and several layers, and two of its mechanisms (field declaration order in memory.rs/disk_store.rs (not opened)) are invisible invariants that no compiler check protects; (b) the Code Review Standards"Supported matrix & compatibility: … every supported … hardware target named in the docs" (line 42) — the Windows path is explicitly unverified and no evidence exists for #609 alone; (c) the "keep it alive forever" idiom is consistent with the existing quarantine doc comment but deliberately leaks on failure paths, and #609 extends it to two more objects. No non-goal (line 28) is touched. — notes #10, #18.
Claims and evidence
| Claim | Backing |
|---|---|
cargo check --all-targets with -D warnings clean (selene + selene-manager) |
Self-reported; no log, no CI link. Packet says CI failed on the head commit. |
541/541 --lib release tests with --features codec |
Self-reported. Plausible against the siblings' counts (#610/#611 claim 542, #612 claims 540), but unverifiable here. |
28/28 FLARE_RUN_CUDA_TESTS=1 SM120 CUDA tests |
Suite is helios::offload::, which this PR does not touch; run on the combined stack. |
Baseline-vs-patched parity across TP1/TP2/TP4, off/cpu/gpu, SM120 + GB10 --roce-ring: 0 panics, 0 quarantined bytes, bit-exact pos0, clean SIGTERM |
Combined 4-PR stack, before rebasing onto #496/#497/#607; only CPU tests re-run post-rebase. Nothing isolates #609. |
| "zero latency or parity regression on SM120 and SM121" | No latency or throughput numbers exist in the PR. |
| Three new unit tests | All three verified present: engine/tests.rs:1571-1589, shared/slice.rs:446-462, selene-manager/src/regions.rs:132-146. But ptr_mut gets only negative bounds asserts and scatter_disjoint is only tested single-threaded, 3-rank — no concurrent test of the aliasing fix. |
| Windows IOCP attach | Explicitly not compiled or executed on Windows. |
— note #3, verified against the diff.
Reach
Affected: anyone running flare run with the Selene pool (host prefix cache / selene-manager), single-host SHM and cross-host --roce-ring RDMA; anyone on the default codec feature (the compressor lifetime change); Windows users (IOCP attach). No wire-protocol change, no on-disk format change, no config/default/CLI change, no dependency change, no public API change (Staging::region/rdma::Device::open are pub(crate)). No docs are updated — nothing documents the new close error or the wider quarantine retention. Observable behaviour: a close can now fail where it previously "succeeded" silently while leaking the memory tier, and the pool status can become PoolStatus::Disabled("a copy could not be drained; memory is quarantined") with memory retained until process exit. — note #11.
Process
Draft vs ready: marked ready and merged the same minute-range; packet says "merged, ready for review". CI failed on head 304dd3a (workflow not identified). No review requested or given; no labels (siblings carry area:selene, bug, triage:review); no autobot intake comment on this PR, whereas #611/#612 both got "Review Stopped — already fixed another way / no longer needed" and #607 got a full "Ready To Merge" review. The PR body does contain all four parts the charter's description standard asks for (why / what changed / claimed result / evidence) plus an unusually candid limitations section. — notes #4, #17.
Open questions / what could not be found
- Which CI job failed on 304dd3a, and whether it is the Windows selene job (
.github/workflows/native-serving.yml:53-55(not opened)), which would bear directly on the only unverified code path. Not resolvable from this vantage point. - No hardware or performance evidence exists for #609 alone; whether the fixes actually work under GPU DMA is asserted, not measured independently.
- Whether the relaxed
offload/tests.rs:659assertion leaves any test covering the close-short-circuit regression it used to catch. - Whether
CompositeStore::close'sdisk.and(memory)(composite.rs:1626) discards a memory close error when both fail — it returns the disk error preferentially. - No linked issue confirms the defects were ever observed in production; no user or operator report was found.