github-vet / github-vet/rangeloop-pointer-findings

openziti/ziti: ziti-fabric-test/subcmd/loop3/dialer.go; 51 LoC

Open
#15,905 0 comments 0 reactions 0 assignees View on GitHub
fresh medium
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [openziti/ziti](https://www.github.com/openziti/ziti) at [ziti-fabric-test/subcmd/loop3/dialer.go](https://github.com/openziti/ziti/blob/06c82fec2c13f8e08c5ccdf386a624a07052393a/ziti-fabric-test/subcmd/loop3/dialer.go#L101-L151)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> range-loop variable conn used in defer or goroutine at line 131

[Click here to see the code in its original context.](https://github.com/openziti/ziti/blob/06c82fec2c13f8e08c5ccdf386a624a07052393a/ziti-fabric-test/subcmd/loop3/dialer.go#L101-L151)

Click here to show the 51 line(s) of Go which triggered the analyzer.

```go
for i, conn := range conns {
name := fmt.Sprintf("%s:%d", workload.Name, i)
resultCh := make(chan *Result, 1)
resultChs[name] = resultCh

go func() {
workload := scenario.Workloads[0]
local := &loop3_pb.Test{
Name: name,
TxRequests: workload.Dialer.TxRequests,
TxPacing: workload.Dialer.TxPacing,
TxMaxJitter: workload.Dialer.TxMaxJitter,
RxRequests: workload.Listener.TxRequests,
RxTimeout: workload.Dialer.RxTimeout,
PayloadMinBytes: workload.Dialer.PayloadMinBytes,
PayloadMaxBytes: workload.Dialer.PayloadMaxBytes,
LatencyFrequency: workload.Dialer.LatencyFrequency,
}
remote := &loop3_pb.Test{
Name: name,
TxRequests: workload.Listener.TxRequests,
TxPacing: workload.Listener.TxPacing,
TxMaxJitter: workload.Listener.TxMaxJitter,
RxRequests: workload.Dialer.TxRequests,
RxTimeout: workload.Listener.RxTimeout,
PayloadMinBytes: workload.Listener.PayloadMinBytes,
PayloadMaxBytes: workload.Listener.PayloadMaxBytes,
LatencyFrequency: workload.Listener.LatencyFrequency,
}

if proto, err := newProtocol(conn); err == nil {
if err := proto.txTest(remote); err == nil {
if err := proto.run(local); err == nil {
if result, err := proto.rxResult(); err == nil {
resultCh <- result
} else {
panic(err)
}
} else {
panic(err)
}
} else {
panic(err)
}
} else {
panic(err)
}
}()

time.Sleep(time.Duration(scenario.ConnectionDelay) * time.Millisecond)
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 06c82fec2c13f8e08c5ccdf386a624a07052393a

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading ziti-fabric-test/subcmd/loop3/dialer.go around lines 101-151, focusing on the loop and goroutine identified by the analyzer. Confirm whether the captured range variable can affect the connection used by the goroutine, then verify that the analyzer finding is resolved and the fabric test behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.