Skip to content

fix: eliminate mutex-copy undefined behaviour in then/eventually.go - #15

Merged
corbym merged 1 commit into
masterfrom
copilot/security-check-repo-dependencies
Apr 2, 2026
Merged

corbym merged 1 commit into
masterfrom
copilot/security-check-repo-dependencies

Conversation

Copilot AI commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

RecordingTestingT embeds sync.Mutex, but was being passed and returned by value in Get(), Merge(), and through the internal channel — all flagged by go vet as mutex-copy violations (undefined behaviour).

Changes

  • Latest.latestValue — changed from RecordingTestingT to *RecordingTestingT
  • Get() / Merge() — signatures updated to accept/return *RecordingTestingT; Merge gains a nil guard for the first call (before any tick value has been recorded)
  • Internal channel — changed from chan RecordingTestingT to chan *RecordingTestingT; goroutine now sends &recordedTesting
  • Timer timeout path — nil-checks Get() result before calling FailedTestOutputs(), covering the case where the timer fires before the first assertion completes
// Before
func (l *Latest) Get() RecordingTestingT          // copies mutex
func (l *Latest) Merge(updated RecordingTestingT) RecordingTestingT  // copies mutex twice
channel := make(chan RecordingTestingT, 1)         // send/receive copy mutex

// After
func (l *Latest) Get() *RecordingTestingT
func (l *Latest) Merge(updated *RecordingTestingT) *RecordingTestingT
channel := make(chan *RecordingTestingT, 1)

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 3.846% (-0.04%) from 3.888%
when pulling 2af6ccb on copilot/security-check-repo-dependencies
into 3601168 on master.

@corbym
corbym merged commit 1fe6447 into master Apr 2, 2026
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants