You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/04/20 13:06:44 UTC
[GitHub] [trafficcontrol] zrhoffman opened a new issue #5761: `go vet`: The cancel function returned by X should be called, not discarded, to avoid a context leak
zrhoffman opened a new issue #5761:
URL: https://github.com/apache/trafficcontrol/issues/5761
<!--
************ STOP!! ************
If this issue identifies a security vulnerability, DO NOT submit it! Instead, contact
the Apache Traffic Control Security Team at security@trafficcontrol.apache.org and follow the
guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
- For *SUPPORT QUESTIONS*, use the Traffic Control slack (https://s.apache.org/atc-slack)
or Traffic Control mailing lists (https://trafficcontrol.apache.org/mailing_lists).
- Before submitting, please **SEARCH GITHUB** for a similar issue or PR.
-->
## I'm submitting a ...
<!-- delete all those that don't apply -->
<!--- security vulnerability (STOP!! - see above)-->
- bug report
## Traffic Control components affected ...
<!-- delete all those that don't apply -->
- Traffic Ops (unit tests)
## Current behavior:
<!-- Describe how the bug manifests -->
`go vet -lostcancel ./...` finds 30 issues:
<table><thead><th>Message</th><th>Line of code</th></thead><tbody>
<tr><td><code>this return statement may be reached without using the cancelTx var defined on line 77</code></td><td>
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/deliveryservice/deleteoldcerts.go#L81
</td></tr>
<tr><td><code>the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak</code></td><td>
<details><summary>Click to expand (27 lines)</summary>
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/api/api.go#L556
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/config_test.go#L127
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/config_test.go#L64
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/deliveryservice_test.go#L224
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/deliveryservice_test.go#L291
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/deliveryservice_test.go#L379
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/deliveryservice_test.go#L442
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/edgelocations_test.go#L90
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/servers_test.go#L183
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/servers_test.go#L434
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/servers_test.go#L470
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/servers_test.go#L521
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/servers_test.go#L589
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/servers_test.go#L631
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/servers_test.go#L675
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/snapshot_test.go#L124
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/snapshot_test.go#L72
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/crconfig/topologies_test.go#L71
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/dbhelpers/db_helpers_test.go#L249
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/deliveryservice/acme.go#L161
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/deliveryservice/acme.go#L220
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/deliveryservice/acme_renew.go#L59
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/deliveryservice/autorenewcerts.go#L105
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/hwinfo/hwinfo_test.go#L85
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/server/servers_assignment_test.go#L90
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/systeminfo/system_info_test.go#L98
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/trafficvault/backends/riaksvc/riak_services_test.go#L185
</details>
</td></tr>
<tr><td><code>the cancelTx function is not used on all paths (possible context leak)</code></td><td>
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/deliveryservice/deleteoldcerts.go#L77
</td></tr>
<tr><td><code>the cancel function returned by context.WithDeadline should be called, not discarded, to avoid a context leak</code></td><td>
https://github.com/apache/trafficcontrol/blob/61e423f33b8f4b61a6228c9e3d0fbac646d231f2/traffic_ops/traffic_ops_golang/login/logout_test.go#L99
</td></tr>
</tbody></table>
## Expected behavior:
<!-- Describe what the behavior would be without the bug -->
`go vet -lostcancel ./...` should find 0 issues.
## Minimal reproduction of the problem with instructions:
<!--
If the current behavior is a bug, please provide the *STEPS TO REPRODUCE* and
include the applicable TC version.
-->
```shell
go vet -lostcancel ./...
```
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] rawlinp closed issue #5761: `go vet`: The cancel function returned by X should be called, not discarded, to avoid a context leak
Posted by GitBox <gi...@apache.org>.
rawlinp closed issue #5761:
URL: https://github.com/apache/trafficcontrol/issues/5761
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org