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/api: "go tool api" panics on certain package names #29837

Closed
ALTree opened this issue Jan 19, 2019 · 3 comments
Closed

cmd/api: "go tool api" panics on certain package names #29837

ALTree opened this issue Jan 19, 2019 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented Jan 19, 2019

$ gotip version
go version devel +5538a9a34f Fri Jan 18 22:41:47 2019 +0000 linux/amd64

The go tool api tool is supposed to be called with package names, like this:

$ gotip tool api fmt

And it correctly prints an error on not-existing package names:

$ gotip tool api badbadbad
2019/01/19 18:59:26 no source in tree for import "badbadbad": stat /home/alberto/go/src/badbadbad: no such file or directory

I noticed it crashes with an invalid memory address or nil pointer dereference on certain words. For example, go:

$ gotip tool api go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5c0468]

goroutine 1 [running]:
go/types.(*Package).Path(...)
	/home/alberto/go/src/go/types/package.go:30
main.(*Walker).export(0xc000099360, 0x0)
	/home/alberto/go/src/cmd/api/goapi.go:232 +0x48
main.main()
	/home/alberto/go/src/cmd/api/goapi.go:173 +0x6df

and cmd:

$ gotip tool api cmd
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5c0468]

goroutine 1 [running]:
go/types.(*Package).Path(...)
	/home/alberto/go/src/go/types/package.go:30
main.(*Walker).export(0xc000099360, 0x0)
	/home/alberto/go/src/cmd/api/goapi.go:232 +0x48
main.main()
	/home/alberto/go/src/cmd/api/goapi.go:173 +0x6df
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 19, 2019
@ALTree ALTree added this to the Go1.12 milestone Jan 19, 2019
@ALTree
Copy link
Member Author

ALTree commented Jan 19, 2019

Tentatively milestoning as 1.12 since the api tool was exposed during the 1.12 release cycle.

@ALTree ALTree changed the title cmd/go: new "go tool api" panics on certain package names cmd/go: "go tool api" panics on certain package names Jan 22, 2019
@ALTree ALTree modified the milestones: Go1.12, Go1.13 Jan 22, 2019
@gopherbot
Copy link

Change https://golang.org/cl/158877 mentions this issue: cmd/api: fix no go files package panic

@bcmills bcmills changed the title cmd/go: "go tool api" panics on certain package names cmd/api: "go tool api" panics on certain package names Jan 22, 2019
@bcmills
Copy link
Contributor

bcmills commented Jan 22, 2019

CC @griesemer @bradfitz

@golang golang locked and limited conversation to collaborators Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants