Skip to content
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

cmd/vet: panic when run with -source starting at CL 38262 #19598

Closed
josharian opened this issue Mar 17, 2017 · 8 comments
Closed

cmd/vet: panic when run with -source starting at CL 38262 #19598

josharian opened this issue Mar 17, 2017 · 8 comments
Milestone

Comments

@josharian
Copy link
Contributor

To reproduce, go to $GOROOT/src and run go tool vet -source .. Results:

panic: path must not be "" or "." [recovered]
	panic: path must not be "" or "."

goroutine 1 [running]:
go/types.(*Checker).handleBailout(0xc4200bae00, 0xc424ceb238)
	/Users/josh/go/tip/src/go/types/check.go:225 +0xa4
panic(0x12714c0, 0x1305cf0)
	/Users/josh/go/tip/src/runtime/panic.go:489 +0x26a
go/types.(*Config).Check(0xc421f7a340, 0x12d0334, 0x1, 0xc4202d4400, 0xc420333518, 0x1, 0x1, 0x0, 0x1, 0x0, ...)
	/Users/josh/go/tip/src/go/types/api.go:351 +0x31e
go/internal/srcimporter.(*Importer).ImportFrom(0xc4202cd290, 0xc42522ec31, 0x9, 0xc4250165a0, 0x15, 0x0, 0x0, 0x0, 0x0)
	/Users/josh/go/tip/src/go/internal/srcimporter/srcimporter.go:137 +0x78c
go/types.(*Checker).importPackage(0xc4200bae00, 0x16, 0xc42522ec31, 0x9, 0xc4250165a0, 0x15, 0x9)
	/Users/josh/go/tip/src/go/types/resolver.go:150 +0x185
go/types.(*Checker).collectObjects(0xc4200bae00)
	/Users/josh/go/tip/src/go/types/resolver.go:243 +0x1cd5
go/types.(*Checker).checkFiles(0xc4200bae00, 0xc42522edb0, 0x2, 0x2, 0x0, 0x0)
	/Users/josh/go/tip/src/go/types/check.go:237 +0xa1
go/types.(*Checker).Files(0xc4200bae00, 0xc42522edb0, 0x2, 0x2, 0xc422d3b650, 0x0)
	/Users/josh/go/tip/src/go/types/check.go:230 +0x49
go/types.(*Config).Check(0xc421f7a180, 0xc42522ec00, 0x4, 0xc421fdff80, 0xc42522edb0, 0x2, 0x2, 0xc4207bdb30, 0xc42086b400, 0xc424ceb468, ...)
	/Users/josh/go/tip/src/go/types/api.go:354 +0x1d2
main.(*Package).check(0xc42594fa40, 0xc421fdff80, 0xc42522edb0, 0x2, 0x2, 0xc42522edc0, 0x1)
	/Users/josh/go/tip/src/cmd/vet/types.go:93 +0x37d
main.doPackage(0xc425023ee0, 0x15, 0xc425016580, 0x2, 0x2, 0x0, 0x0)
	/Users/josh/go/tip/src/cmd/vet/main.go:340 +0x14c
main.doPackageDir(0xc425023ee0, 0x15)
	/Users/josh/go/tip/src/cmd/vet/main.go:288 +0x583
main.visit(0xc425023ee0, 0x15, 0x142be00, 0xc4259736c0, 0x0, 0x0, 0x0, 0x0)
	/Users/josh/go/tip/src/cmd/vet/main.go:375 +0xd9
path/filepath.walk(0xc425023ee0, 0x15, 0x142be00, 0xc4259736c0, 0x12e0560, 0x0, 0x0)
	/Users/josh/go/tip/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0xc42523d7e0, 0xf, 0x142be00, 0xc423f87d40, 0x12e0560, 0x0, 0x0)
	/Users/josh/go/tip/src/path/filepath/path.go:376 +0x40c
path/filepath.walk(0xc424b987d8, 0x6, 0x142be00, 0xc421de3520, 0x12e0560, 0x0, 0x0)
	/Users/josh/go/tip/src/path/filepath/path.go:376 +0x40c
path/filepath.walk(0xc42184d115, 0x3, 0x142be00, 0xc42166aa90, 0x12e0560, 0x0, 0x0)
	/Users/josh/go/tip/src/path/filepath/path.go:376 +0x40c
path/filepath.walk(0x7fff5fbff8a5, 0x1, 0x142be00, 0xc420085520, 0x12e0560, 0x0, 0xc420043e78)
	/Users/josh/go/tip/src/path/filepath/path.go:376 +0x40c
path/filepath.Walk(0x7fff5fbff8a5, 0x1, 0x12e0560, 0xc, 0xc420085450)
	/Users/josh/go/tip/src/path/filepath/path.go:398 +0x14c
main.walkDir(0x7fff5fbff8a5, 0x1)
	/Users/josh/go/tip/src/cmd/vet/main.go:390 +0x41
main.main()
	/Users/josh/go/tip/src/cmd/vet/main.go:244 +0x32b

This is why the vetall builder is currently red. Haven't investigated whether the CL is the problem or whether it uncovered an existing problem.

cc @mvdan @griesemer

@josharian josharian added this to the Go1.9 milestone Mar 17, 2017
@mvdan
Copy link
Member

mvdan commented Mar 17, 2017

My guess is that it uncovered a misuse of Check. Thanks for filing the bug.

@mvdan
Copy link
Member

mvdan commented Mar 17, 2017

Perhaps related to how you're using "." as an argument. If I understand correctly, you have to give the full import path (absolute, not relative) to go/types.

Does it fail if you give it explicitly, like $(go list .)?

@josharian
Copy link
Contributor Author

'go tool vet -source pwd' panics, the same way.

@josharian
Copy link
Contributor Author

I traced this down a little bit.

In the packages that fails (cmd/go/testdata/local) we're passing "main" as the path to config.Check. Note that that package has an import "./easysub" in it.

In srcimporter.Importer.ImportFrom, that goes into the build.IsLocalImport(path), gets resolved using p.ctxt.ImportDir, and the resulting package has bp.ImportPath == ".".

I'm not sure where in this chain of events something has gone wrong, but I don't think vet is doing anything wrong here. I suspect that srcimporter does not correctly handle relative imports, one way or another.

@josharian
Copy link
Contributor Author

Once this is resolved, re-submit CL 38262.

@griesemer
Copy link
Contributor

@josharian Thanks for looking into this; and my apologies for not looking at the one failure more carefully.

@rsc rsc modified the milestones: Go1.10, Go1.9 Jun 22, 2017
@ALTree
Copy link
Member

ALTree commented Nov 10, 2017

I can't reproduce this on tip go version devel +3231d4e4ef Fri Nov 10 10:56:22 2017 +0000 linux/amd64. Possibly already fixed?

@rsc
Copy link
Contributor

rsc commented Nov 22, 2017

Maybe fixed, and maybe we'll just remove -source entirely anyway.

@rsc rsc closed this as completed Nov 22, 2017
@golang golang locked and limited conversation to collaborators Nov 22, 2018
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