Data race on state.State between mailbox goroutines ai:claude-sonnet-5-5 #46
Labels
No labels
nagonag
nagonag/ignore
bug
doc
duplicate
enhancement
help wanted
invalid
question
security
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
IUS/xr-invoiced#46
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found by a 100 Go Mistakes review (#58 race problems, #69). Verified by reading the code; not reproduced (no existing test runs more than one mailbox).
Where:
internal/app/app.go:612-660(Run),scanDelta,RunMailbox;internal/state/state.go:60(States.Save).Problem: each mailbox goroutine mutates its own
*state.State(LastUID,HighestModSeq, ...) without a lock.saveStatesholdssaveMu, butStates.Savemarshals the whole map, including other mailboxes' structs that are being written concurrently. With two or more mailboxes this is a data race (go test -racewith a multi-mailbox test should flag it) and can persist torn values.Fix: guard each
Statewith its own mutex, or perform state updates insidesaveStatesundersaveMu. Add a multi-mailbox test run under-race.(co)authored by ai:claude-sonnet-5-5