Repository navigation
fix(moq-net): an origin with a closed lite-07 session's orphan tears down and frees its route node - #9106
fix(moq-net): an origin with a closed lite-07 session's orphan tears down and frees its route node#9106kixelated wants to merge 1 commit into
Conversation
…down and frees its route node Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Approach: Sound. The fix handles both causes of the leak. Disowning the orphan's Keepalive lets the driver reach teardown, and teardown then breaks the OriginState::route_node → orphan → RouteState → origin-state cycle. This keeps orphans visible while the origin lives and doesn't weaken the node, which would have defeated reconnects.
Reviewed changes
The full diff of the single commit, checked against origin.rs, route/node.rs and lite/subscriber/routed.rs.
Claim::disown:RouteState's keepalive becomes aMutex<Option<Keepalive>>thatRouted::orphanclears before leavingLeftin the node.- Forwarded claims carry
publisher: None, so this removes all of the orphan's ownership. - A reconnecting session serves a fresh
Claimand the disowned orphan is released, so a live claim is never disowned.
- Forwarded claims carry
- Teardown frees the node:
DriverState::teardowntakesshared.route_nodeunder the lock and drops it outside.RouteState::drop→retractneeds the shared lock, so dropping outside it avoids a deadlock.TaskSet::owned()replaces the old set before this point, which cancelsFeedOwnClaimsandRouteTimerand drops their node clones.
- No node after close:
create_route_nodestops storing a node onceclosedis set.Tasks::pushalready refuses work after close, so a lateroute_node()call leaves nothing behind. - Tests and fixtures:
- New
a_torn_down_origin_lets_go_of_what_closed_sessions_left, using a test-onlyWeakNode. - The
source_errorsfixture now holds its relay origin. - The drill patch context is updated for the new
disown()line.
- New
claude-opus-5-5 | 𝕏
|
No actionable comments were generated in the recent review. WalkthroughRoute claims now store keepalives in optional mutex-protected state, which Merge Risk:
|

Problem
Nightly
Fuzz (session_lite)(run 44342367698) exits 77: LeakSanitizer reports about 33 KB of indirect leaks on the very first corpus input ([0], a lite-07 session with an empty script). Every lite-07 session run leaks.Since moq-dev/moq#8987, a lite-07 session that closes leaves each claim it served in the origin's route node as an orphan (
routed::Left, which holds anorigin::Claim). That makes two problems:OriginState::route_node), the node holds the orphan, and the orphan's claim holds the origin's shared state again. Nothing breaks that cycle, not even teardown, so the whole origin (table, broadcasts, sessions' route state) leaks.Keepaliveon the origin's driver, so an orphan keeps the driver running after everyProducerhandle and session is gone. The orphan only goes away when another session serves the claim or the node's reader lets it go, and that reader runs inside the same driver, so it never does.Approach
Claim::disowndrops its keepalive). What a closed session left behind is not an owner, like the other read handles: it keeps the claim shown while the origin lives, and goes away with the origin.route_node()call after teardown no longer stores a fresh node.source_errorsintegration fixture now holds its relay origin, as a real relay does. It had relied on the dead upstream's orphan to keep an origin with no owner alive.relay-withdraws-lost-publisheris retargeted at the new line. It still breaks its drill.Validation
cargo fuzz run session_liteon the logged input ([0]): the same LeakSanitizer report, 93 allocations. After symbolizing it, the leaked roots wereroute::node::Node::newfromConsumer::route_nodeand the origin'sProducer::new. With the fix, the input runs clean.cargo fuzz run session_litefrom the generated seeds: 10k runs, no leak or failure.a_torn_down_origin_lets_go_of_what_closed_sessions_left: a session serves a claim and closes, then the origin's handles drop, and the test asserts the route node is freed. It fails if either half of the fix is removed, each checked separately.just rs test -p moq-net --all-features: 3905 passed.just checkpasses, including the drill sensitivity check.fuzz/regressions/session_lite: the input is[0], which the seeds already cover, and the stable replay runs without LeakSanitizer. The unit test holds the regression instead.Caused by
Impact
ProducerandRoutehandles have dropped now finishes and tears down once its live sessions end, even when a closed lite-07 session left claims behind. Before, those orphans kept it running forever. No public API or wire change.Alternatives
Waiting
origin::Driver's docs. A relay always holds its origin, so its behavior is unchanged. Recommendation: keep this.Models
Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort
(Written by Opus 5.5)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 839c215
Base: origin/main at 6f420bf
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1f04b-00e9-7132-b255-04a0340d7c23, round 1Score: 9/10,
The ownership changes address the reference cycle coherently and include regression coverage; no actionable regressions were found, but builds and tests were not run as instructed.Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none