github-vet / github-vet/rangeloop-pointer-findings
maseology/rdrr: model/evaluateSubdomain.go; 61 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [maseology/rdrr](https://www.github.com/maseology/rdrr) at [model/evaluateSubdomain.go](https://github.com/maseology/rdrr/blob/802c24277112b850003b4c72109a1812b81adf90/model/evaluateSubdomain.go#L49-L109)
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 i used in defer or goroutine at line 96
[Click here to see the code in its original context.](https://github.com/maseology/rdrr/blob/802c24277112b850003b4c72109a1812b81adf90/model/evaluateSubdomain.go#L49-L109)
Click here to show the 61 line(s) of Go which triggered the analyzer.
```go
for i, k := range b.swsord {
if print {
// fmt.Printf("--> round %d (of %d): %d sws\n", i+1, nrnds, len(k))
tt.Print(fmt.Sprintf("--> round %d (of %d): %d sws", i+1, nrnds, len(k)))
}
chstrans := make(chan stran, len(k))
for _, sid := range k {
wg.Add(1)
go func(sid int, t []itran) {
defer wg.Done()
pp := newEvaluation(b, p, Ds, m, sid, print)
if len(t) > 0 {
pp.sources = make(map[int][]float64, len(t)) // upstream inputs
for _, v := range t {
if _, ok := pp.sources[pp.cxr[v.c]]; ok {
for i, vv := range v.v {
pp.sources[pp.cxr[v.c]][i] += vv
}
// log.Fatalf("TODO (subdomain.eval): more than one sources transferred to the same cell: sid: %d, cell: %d\n", sid, v.c)
} else {
pp.sources[pp.cxr[v.c]] = v.v
}
}
}
if sid == b.cid0 { // outlet
rs := newResults(b, nstep)
rs.dt, rs.obs = b.frc.T, b.frc.O[0]
var res resulter = &rs
if print {
fmt.Printf(" printing SWS %d\n\n", sid)
}
ver(&pp, Ds, m, res, b.mon[sid])
of = res.report(print)[0]
// outflw = rs.sim
} else {
var res resulter = &outflow{}
if print {
fmt.Printf(" running SWS %d\n", sid)
}
ver(&pp, Ds, m, res, b.mon[sid])
dsid := -1
if d, ok := b.rtr.Dsws[sid]; ok {
// if _, ok := transfers[d]; !ok {
// transfers[d] = []itran{} //// concurrent map write potential (now fixed below)
// }
dsid = d
}
chstrans <- stran{s: dsid, i: itran{c: b.ds[sid], v: res.report(false)}}
}
}(sid, transfers[sid])
}
wg.Wait()
close(chstrans)
for t := range chstrans {
if _, ok := transfers[t.s]; !ok {
transfers[t.s] = []itran{t.i}
} else {
transfers[t.s] = append(transfers[t.s], t.i)
}
}
}
```
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: 802c24277112b850003b4c72109a1812b81adf90
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.