Repository navigation
fix(check): close the phase-resync goroutine leak + its data race - #75
Merged
Merged
Conversation
runWithPhaseResync spawned a per-boundary credential-resync goroutine but returned via cmd.Wait() without awaiting them, so a resync goroutine (and its credential `podman cp`) could outlive the run — a real production goroutine leak the -race detector also caught as a phaseResyncFn read/write race. Root-cause synchronization (no -race suppression): a sync.WaitGroup barrier so no resync goroutine outlives the return; a mutex around the boundary test's concurrent seenScore writes (a second race surfaced once the first closed); and deletion of the failure-path test's time.Sleep(100ms) R4 bandaid (the WaitGroup is the real primitive it approximated). Gate: go test -race -run 'TestRunWithPhaseResync|TestHarnessPhaseRe' (0 races, was 2) + full go test ./charly/... + build + golangci-lint (0) + gofmt. Assisted-by: Claude (fully tested and validated) Claude-Session: https://claude.ai/code/session_01QsHyDfHPTARnrmNZiw1ABX
Contributor
Author
pr-validator — APPROVED ✅Change class: charly/ Go code (concurrency / goroutine-lifecycle fix + test) I re-derived this verdict independently (fresh context), re-running every gate against the feat head merged with current main (the actual landing state) in an isolated worktree. Independent re-run evidence
The pre-fix run confirms the test genuinely catches the defect (R10 check-coverage: it FAILS without the fix, PASSES with it). Checklist
Decision: This is a correct, complete, root-cause fix for a real production goroutine leak + its data race. The synchronization is textbook-correct, the test proves the defect is caught, and every Go gate re-ran green on the merged landing state. Approving and finalizing the merge-time CalVer. Assisted-by: Claude (analysed on a live system) |
Version-stamp commit (pr-validator): rename the placeholder CHANGELOG to the merge-time CalVer and align its H1. Folded into the squash-merge of #75. Assisted-by: Claude (fully tested and validated) Claude-Session: https://claude.ai/code/session_017QzXFEfS9HFXZrU2b2Xokh
atrawog
added a commit
that referenced
this pull request
Jul 12, 2026
Docs-only follow-up to #75: the CalVer finalization renamed the placeholder changelog but left its H1 at the placeholder date; this aligns the H1 (# 2026.193.1611) to the filename. Assisted-by: Claude (documentation reviewed)
atrawog
added a commit
that referenced
this pull request
Jul 14, 2026
…ks + module-key validation fix The check/bed correctness batch — three pre-existing bed/validation defects landed as one atomic superproject cutover (producer legs merged first: sdk#47 image_tag wire field + plugins#55 agents-SKILL R1 correction). #75 — bed-scoped fixture image tags (the shared-tag concurrency collision class): a per-run <bed-root>-<runCalver> tag threaded via spec.CheckBedReply.ImageTag, passed as --tag on every build + deploy, with resolveNodeOverlays seeding node.Version and the k8s preresolver honoring it (mirroring build_overlay's tag!="" branch). Retention-safe (same image name → same label group). #66 — debootstrap-builder baked checks: qemu-img version scalar-equals → contains matcher (R4); grub-install check kept (correct) + the missing grub2-common added (provides /usr/sbin/grub-install, dropped by --no-install-recommends). #71 — validatePkgConfig module/modules Raw-key mismatch: Raw["modules"]→Raw["module"] (the singular authored key), making the rule reachable; discriminating test + guard. sdk gitlink → merged 5ad481d (v0.2026195.742); plugins gitlink → merged 7075eda (v2026.195.0759). Validated independently by a fresh pr-validator: delta re-gate green after update-branch (golangci-0 + tests on all 3 modules), forward-gitlinks verified, #75 concurrent-pair R10 corroborated. Assisted-by: Claude (fully tested and validated)
8 tasks done
atrawog
added a commit
that referenced
this pull request
Jul 14, 2026
#77, #76) vm-lifecycle-correctness thematic batch — two non-blocking correctness fixes, one squash. #77 — `charly vm stop` backend-mismatch false-success (the stop sibling of #69's vm-destroy). Extract `vmHolder` (the authoritative "which backend ACTUALLY holds this domain" probe) shared with #69's `destroyVmDomain` (R3 — ONE shared abstraction, never a duplicate); `destroyVmDomain` is refactored to use it byte-equivalently. Add `stopVmDomain` (probe + stop + poll-for-shutoff verify — the same `pollUntil`/`StopGate` primitive `gracefulStopDomain` uses for destroy). Rewrite `charly vm stop` to use it; a nonexistent VM errors "no such VM" (mirroring #69 destroy) instead of false-success. The libvirt stop is an ASYNC ACPI poweroff, so the verify POLLS for the domain to leave `DomainRunning` (exactly what `vm list -a` reports as "running") rather than re-probing immediately (which false-positives mid-shutdown — confirmed live); only a guest still running after the grace errors, pointing at `charly vm stop --force`. The core `stopVM` (arbiter `holderStop`) is the same class in a separate code path — registered for the next vm-lifecycle cutover (cross-package kit unification of the duplicated stop/qemu/vmDir helpers). #76 — the out-of-tree plugin build cache (`~/.cache/charly/plugins/<name>`) was word-keyed shared-mutable state: two worktrees building the same plugin word raced the one `go build -o` output (the #75 shared-image-tag collision class). Scope the cache path by source dir (`pluginSourceTag`, a 16-hex digest of the absolute srcDir — always-rebuild, no cache-hit skip, so a dependency bump never serves a stale binary) + atomic publish (build to `bin.build` under the per-binary lock, then `os.Rename`) so a reader never sees a half-written binary. R10: `check-charly-vm` bed exit 0 / 7 steps ok (exercised `vmHolder` via the destroy teardown + #76 plugin builds with the new source-scoped cache paths — the `<tag>` suffix in every built plugin path is `pluginSourceTag`); live `charly vm stop` on a disposable SSH-ready `charly-vm` -> "Stopped VM" + verified `shut off` (rc=0); unit tests (`vm_stop_test.go`, `plugin_build_cache_test.go`) + golangci-lint 0 (charly / plugin-vm) + `task build:binary`. Assisted-by: Claude (fully tested and validated)
This was referenced Jul 29, 2026
refactor(core)!: #55 step-4 — charly + in-tree candies off sdk/deploykit for the InstallStep IR
#198
Merged
atrawog
added a commit
that referenced
this pull request
Aug 17, 2026
plugins#198 merged as da76ec0f and was tagged v2026.229.2154, after seven rounds. The pin moves 0e6351c (my branch head) -> da76ec0f (the squash on plugins/main). Re-derived from plugins/origin/main, NOT the PR head: the CalVer commit and the squash both move the ref. The ancestry gate was fed the unmerged 0e6351c first and correctly rejected it. docs remains at b3dfd1e deliberately -- docs#73 merged, and the round-7 fixes that landed on the re-created branch afterwards are now docs#75, still open. That pin gets the same re-derivation when #75 lands, and this PR must not merge before then. Assisted-by: Claude Code Anthropic Claude Opus 5 (documentation reviewed)
This was referenced Nov 27, 2026
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.
Root cause (a real production defect, not only a test race)
runWithPhaseResync(charly/check_runner_cmd.go) — the in-pod iterateorchestrator's per-phase credential-resync driver — spawns a resync goroutine at
every phase boundary it scans on the harness subprocess's stderr, then returns via
cmd.Wait().cmd.Wait()blocks on the SUBPROCESS, not the goroutines — so aresync goroutine, and the credential
podman cpitsphaseResyncFnperforms, couldoutlive the run's return (a leaked goroutine + in-flight side-effect). A
-racerun of the check-runner tests caught the same leak as a data race: the leaked
goroutine reads the
phaseResyncFnpackage-var while the test'sdefer phaseResyncFn = origFnrestore writes it.Fix — root-cause synchronization (no
-racesuppression)sync.WaitGroupbarrier: every boundary goroutine isAdd/Done-tracked, andrunWithPhaseResynccallswg.Wait()aftercmd.Wait()before returning — noresync goroutine (nor its
phaseResyncFnread) outlives the return. Closes both thegoroutine leak and the read/write race at the root.
-raceonce the first closed): the boundarytest's mock wrote a shared
seenScorefrom all N concurrent resync goroutines →guarded with a mutex.
time.Sleep(100ms)"let the goroutinefinish" hack is removed — the
WaitGroupbarrier is the real primitive it approximated.Verification (R10 — go-test gate for this class, no bed)
go test -race -run 'TestRunWithPhaseResync|TestHarnessPhaseRe' ./charly/→ 0 races (was 2)go test ./charly/...→ greengo build ./...+golangci-lint run(0 issues) +gofmtclean(The full
-race -count>1stress stays gated on the provider-registry test-isolationseam, tracked separately; single-test
-raceis the correct gate here.)Peeled from the P12 check-externalization worktree as its own immediate cutover (it's a
real production fix affecting
mainnow + clears the team-wide-racenoise); P12rebases onto it.
Assisted-by: Claude (fully tested and validated)
https://claude.ai/code/session_01QsHyDfHPTARnrmNZiw1ABX