ylorn (v0.1.1250, macOS arm64, ~/.config a symlink): ~10s after every
start the GUI froze, beachball, CPU ~0, SIGTERM ignored. Their SIGQUIT
stack: the window's resize timer -> settings.Save (fileMu write lock) ->
edit.WriteAtomic -> the sync's filter keptAway -> gateway.URL ->
settings.Load -> fileMu.RLock, the same lock, forever.
Cause: edit.Filtered's filter sees every file written through edit while
a sync runs, from any goroutine, under whatever lock the writer holds.
keptAway read the settings (gateway.URL, and access.LANSecret through
ourToken) inside it, and skipped magpie's own files by a prefix check on
the unresolved ~/.config/magpie while WriteAtomic hands it the path
edit.Target resolved, so with a linked ~/.config settings.json fell
through to the settings read.
Fix (the class): what the filter needs of this magpie, the gateway's
address and the LAN key, is read before it is on (keeping(), kept.away,
kept.ours), so the filter takes no settings or access lock. magpieFile
compares magpie's folder as named and as EvalSymlinks resolves it, with
the written file's folder resolved too (for a file not there yet).
Siblings found: wslSaveLocked writes wsl.json under wsl's mutex, and the
filter's wslHost takes that mutex: with a linked config folder the same
self-deadlock on Windows (now skipped as magpie's own; the test covers
it). access.save writes keys.json under access.mu, which LANSecret took
inside the filter (now read before). No other prefix check against
provider.Path()/appdir gets a Target-resolved path; the filter is
edit.Target's only consumer of that kind. edit.Filtered's doc now says
the filter waits on nothing.
Run at this head (macOS arm64, go1.26.8, -tags nogui, -p 1):
- TestOwnWritesDuringASyncWithALinkedConfig (new; sandbox HOME with
.config a symlink): on origin/main 35aa50cfb it fails with the
reporter's stack (settings.go:972 <- keptaway.go:92 <- settings.go:1324).
- go test ./internal/agent (whole package, 810s): ok
- go test ./internal/edit: ok
- -race TestOwnWrites...|TestKeptAwayOnlyWhatIsSure -count=2: ok
- gofmt -l clean; GOOS=darwin/linux/windows go vet ./internal/agent
./internal/edit: ok
Broken by hand:
- magpieFile comparing the unresolved folder only (settings read kept
out of the filter): red, wsl.json deadlocks in wslHost.
- the settings read put back inside the filter, own check fixed: green
(settings.json is skipped as magpie's own before it); with the old
check as well: red with the reporter's stack. The hoist is guarded only
together with the own check.
Not tried: the real GUI with a linked ~/.config; the Windows box.
Full suite: SUITE_LINE