Skip to content

all: vet context failures #16230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
josharian opened this issue Jun 30, 2016 · 11 comments
Closed

all: vet context failures #16230

josharian opened this issue Jun 30, 2016 · 11 comments
Milestone

Comments

@josharian
Copy link
Contributor

The cmd/vet context check and the context package/methods were all added in 1.7. There are numerous complaints from vet about the stdlib. For most of them, we should probably either fix the stdlib or the vet check before release. This issue is to investigate them.

context/withtimeout_test.go:16: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak
net/http/h2_bundle.go:2000: the cancel function is not used on all paths (possible context leak)
net/http/h2_bundle.go:2005: this return statement may be reached without using the cancel var defined on line 2000
net/http/server.go:778: the cancelCtx function is not used on all paths (possible context leak)
net/http/server.go:787: this return statement may be reached without using the cancelCtx var defined on line 778

cc @bradfitz @alandonovan

@josharian josharian added this to the Go1.7 milestone Jun 30, 2016
@bradfitz
Copy link
Contributor

Only the first looks real. We should fix ExampleWithTimeout to not be a bad example of what not to do.

The http ones are bogus.

@adonovan
Copy link
Member

The HTTP ones are due to a bug in the vet check: a "naked" return should count as a reference to the named result variables.

@ianlancetaylor
Copy link
Contributor

@adonovan do you think you can fix the vet check by the end of the week?

@adonovan
Copy link
Member

Yes.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/24681 mentions this issue.

@alandonovan
Copy link
Contributor

alandonovan commented Jun 30, 2016

(Not fixed yet --- https://go-review.googlesource.com/c/24681/ still pending.)

@josharian
Copy link
Contributor Author

This doesn't look entirely fixed. At 54b499e, running go vet net/http yields:

net/http/server.go:778: the cancelCtx function is not used on all paths (possible context leak)
net/http/server.go:787: this return statement may be reached without using the cancelCtx var defined on line 778

@josharian josharian reopened this Jul 9, 2016
@bradfitz
Copy link
Contributor

Okay, those two are valid. Sent https://go-review.googlesource.com/24850

I disagree with these two:

transfer.go:217: net/http/internal.FlushAfterChunkWriter composite literal uses unkeyed fields
exit status 1
transport_test.go:120: arg c for printf verb %p of wrong type: net.Conn

Both of those are intentional. For the first, I think cmd/vet should ignore that rule on internal packages. And for the second, I think we need to define in the fmt package what %p means on interfaces.

@josharian
Copy link
Contributor Author

I think cmd/vet should ignore that rule on internal packages.

I have a CL pending for 1.8 that changes transfer.go. It's a tiny change that's not obviously better or worse, and I'm unconvinced that changing vet is the right answer. But let's discuss that on the CL or during 1.8. The only thing that matters for 1.7 is the context stuff.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/24850 mentions this issue.

gopherbot pushed a commit that referenced this issue Jul 11, 2016
Updates #16230

Change-Id: Ie38f85419c41c00108f8843960280428a39789b5
Reviewed-on: https://go-review.googlesource.com/24850
Run-TryBot: Brad Fitzpatrick <[email protected]>
Reviewed-by: Josh Bleecher Snyder <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
@josharian
Copy link
Contributor Author

We can close this. The context-related failures were fixed by CL 24850. I'll deal with anything else in 1.8 as part of getting vet running during all.bash.

@golang golang locked and limited conversation to collaborators Jul 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants