release-23.1: linter: loopvarcapture should check interface methods #103088
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.
Backport 1/1 commits from #102679 on behalf of @srosenberg.
/cc @cockroachdb/release
The
loopvarcapture
linter is part ofroachvet
. It flags incorrect uses of loop variables captured by reference in Go routines or defer statements--a common source of data races.In addition to checking Go routines created via the
go
keyword, the linter also checks against other (internal) APIs, which are known to create Go routines; this is specified viaGoRoutineFunctions
.An existing bug prevented the linter from checking inside
Monitor.Go
, which are commonly used inside roachtests.This PR fixes the linter bug as well as the pre-existing bug inside a roachtest, which this linter now detects.
This PR also removes the uncessary hack, i.e.,
RunDespiteErrors
, introduced in [1]. By allowing the type checker to swallow errors, the test was susceptible to silent errors, e.g., buggy testdata. Instead, we work around by disabling CGO.Epic: none
Fixes: #102678
Release note: None
Release justification: CI only change
[1] #84867 (comment)
Release justification: