Repository navigation
Description
A disposal audit of the node's cross-platform projects (OpenClaw.Connection, OpenClaw.Shared, OpenClaw.SetupEngine) with a static analyzer surfaced a set of IDisposables that are created but never disposed. After reading each site closely, most turned out to be correct as-is — the one genuinely worth fixing is a dead, unused Process allocation. Recording the full analysis here for transparency.
How these were found: a static disposal audit with klammerkrebs, a Roslyn-native IDisposable-leak analyzer I'm building (sibling to signalkrebs/marmorkrebs; https://github.com/anagnorisis2peripeteia/klammerkrebs). It resolves IDisposable through a real Roslyn compilation — semantic, not pattern-matching — and flags a disposable stored in a field/collection that the owning type never disposes. The tool surfaces candidates; every one below was then read by hand, and as it turned out most were correctly rejected — the proof is manual, not generated.
Actionable — one real fix
-
OpenClaw.SetupEngine/SetupSteps.cs,GetProcessCommandLine—var result = new System.Diagnostics.Process();is allocated and then never used; the method does its work through a separateusing var p = Process.Start(psi). Becauseresultis neverStart()ed it holds no OS handle, so this is dead code (an unused allocation) rather than a runtime leak — but it's a clear leftover. Fix: delete the line. → chore: remove dead unused Process allocation in GetProcessCommandLine #1004
Reviewed — leaving as-is (recorded for the record)
The remaining candidates are async-only SemaphoreSlim/CancellationTokenSource fields, and disposing them would be net-negative on two counts:
Dispose()frees nothing here. None of these ever touchAvailableWaitHandle, so no wait handle is allocated andSemaphoreSlim.Dispose()is a no-op — there's no leak to close.- Disposing them would add a race. Each releases in an unguarded
finally(e.g.WebSocketClientBase.SendRawAsync'sfinally { _sendLock.Release(); }). If an operation is in flight whenDispose()runs, thatRelease()would then throwObjectDisposedExceptionout of afinally, into a fire-and-forget task.
This is the same reasoning already applied deliberately to WebSocketClientBase._cts (whose comment explains it's left for GC on purpose). The semaphores are simply the same choice, uncommented:
WebSocketClientBase._sendLock,WindowsNodeClient._invokeSemaphore,NodeConnector._connectSemaphore,GatewayConnectionManager._nodeStartSemaphoreExecApprovalsCoordinator._promptLock,ExecApprovalsStore._lock(also async-only; the types aren'tIDisposable, and making them so to dispose a no-op semaphore isn't worth the added surface)
If the maintainers do want these CA2213-clean, the only safe route is guarding every Release() with try/catch (ObjectDisposedException) before disposing — happy to do that, but it adds noise for no runtime gain, so I'd lean against. A short // intentionally not disposed — async-only, Dispose is a no-op note on each (matching the existing _cts comment) might be the more useful outcome, if wanted.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsChannels
Activity
[-]Tracking: undisposed IDisposable fields in the Windows node (SemaphoreSlim disposal hygiene + a dead Process)[/-][+]Disposal audit of the Windows node: one dead Process to fix; async SemaphoreSlim/CTS fields reviewed and left as-is[/+]chore: remove dead unused Process allocation in GetProcessCommandLine (…
clawsweeper commentedon Jul 17, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 16, 2026, 6:23 PM ET / 22:23 UTC.
Summary
Keep open because current
mainstill contains the reported dead allocation and the linked same-author pull request is the active implementation candidate; the issue should remain open until that pull request merges or closes.Reproducibility: yes. from source inspection: current
mainconstructs an unusedProcessinGetProcessCommandLine, and the object is never referenced or started. This is a deterministic dead-code observation rather than a runtime resource-leak reproduction.Next step
The exact repair is already owned by the open linked pull request, so ClawSweeper should not create a competing fix branch.
Review details
Best possible solution:
Land the narrow deletion through the linked pull request after the repository-required Windows validation, then close this issue while preserving the current async semaphore and cancellation-token lifetime behavior unless separate runtime evidence establishes a real leak.
Do we have a high-confidence way to reproduce the issue?
Yes, from source inspection: current
mainconstructs an unusedProcessinGetProcessCommandLine, and the object is never referenced or started. This is a deterministic dead-code observation rather than a runtime resource-leak reproduction.Is this the best way to solve the issue?
Yes. Deleting only the unused allocation is the narrowest maintainable fix; adding disposal machinery to the unrelated async synchronization fields would expand scope and could introduce shutdown races without demonstrated benefit.
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning high; reviewed against e0afbc425fb7.
Label changes
Label changes:
P3: This is a behavior-preserving, one-line dead-code cleanup with no reported user-facing impact.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.Label justifications:
P3: This is a behavior-preserving, one-line dead-code cleanup with no reported user-facing impact.Evidence reviewed
What I checked:
GetProcessCommandLinestill constructs an unusedSystem.Diagnostics.Processbefore creating and starting the separate process that performs the query. citeturn12view0. (src/OpenClaw.SetupEngine/SetupSteps.cs, e0afbc425fb7)4750440df50b7c1c95e1203cd01d37dc629f4cc0. (src/OpenClaw.SetupEngine/SetupSteps.cs, 4750440df50b)AGENTS.md, e0afbc425fb7)v0.6.12as the latest release, while the reported allocation remains present at the newer current-main SHA; the cleanup is therefore not implemented on main or proven shipped. (src/OpenClaw.SetupEngine/SetupSteps.cs, e0afbc425fb7)Likely related people:
src/OpenClaw.SetupEngine/SetupSteps.cs)src/OpenClaw.SetupEngine/SetupSteps.cs,docs/SETUP_ENGINE_REDESIGN.md)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.