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: SIGSEGV in the presence of duplicate function definitions #19656

Closed
jgrahn opened this issue Mar 22, 2017 · 3 comments
Closed

cmd/vet: SIGSEGV in the presence of duplicate function definitions #19656

jgrahn opened this issue Mar 22, 2017 · 3 comments

Comments

@jgrahn
Copy link

@jgrahn jgrahn commented Mar 22, 2017

Running go vet (version go1.8 darwin/amd64) on a package as defined below results in a SIGSEGV panic.

What version of Go are you using (go version)?

go1.8 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin"

What did you do?

Created a package directory containing two identical files, named 1.go and 2.go, having the following content:

package main

import "context"

func f() {
	var ctx, cancel = context.WithCancel(context.Background())
}

Then ran go vet {package} on that package.

What did you expect to see?

Ideally a vet error notifying about the duplicate function definition. Alternatively two vet errors warning about the lost context cancel, once for each file. Not a crash.

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x12321b7]

goroutine 1 [running]:
main.checkLostCancel(0xc420080600, 0x13f16a0, 0xc4201f0e10)
	/usr/local/Cellar/go/1.8/libexec/src/cmd/vet/lostcancel.go:107 +0x767
main.(*File).Visit(0xc420080600, 0x13f16a0, 0xc4201f0e10, 0x13f0760, 0xc420080600)
	/usr/local/Cellar/go/1.8/libexec/src/cmd/vet/main.go:500 +0x104
go/ast.Walk(0x13f0760, 0xc420080600, 0x13f16a0, 0xc4201f0e10)
	/usr/local/Cellar/go/1.8/libexec/src/go/ast/walk.go:52 +0x66
go/ast.walkDeclList(0x13f0760, 0xc420080600, 0xc4201f3280, 0x2, 0x2)
	/usr/local/Cellar/go/1.8/libexec/src/go/ast/walk.go:38 +0x89
go/ast.Walk(0x13f0760, 0xc420080600, 0x13f1660, 0xc4200a5500)
	/usr/local/Cellar/go/1.8/libexec/src/go/ast/walk.go:353 +0x2bb4
main.(*File).walkFile(0xc420080600, 0x7fff5fbffa41, 0xd, 0xc4200a5500)
	/usr/local/Cellar/go/1.8/libexec/src/cmd/vet/main.go:467 +0x120
main.doPackage(0x12d07b4, 0x1, 0xc42008c010, 0x2, 0x2, 0x0, 0xffffffffffffffff)
	/usr/local/Cellar/go/1.8/libexec/src/cmd/vet/main.go:358 +0xbd1
main.main()
	/usr/local/Cellar/go/1.8/libexec/src/cmd/vet/main.go:247 +0x382
exit status 2
@jgrahn jgrahn changed the title SIGSEGV in `go vet` in the presence of duplicate function definitions cmd/vet: SIGSEGV in the presence of duplicate function definitions Mar 22, 2017
@bradfitz bradfitz added this to the Go1.9 milestone Mar 22, 2017
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Mar 22, 2017

@josharian

This comment has been minimized.

Copy link
Contributor

@josharian josharian commented Mar 22, 2017

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Mar 22, 2017

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

@gopherbot gopherbot closed this in 3b39f52 Mar 22, 2017
@golang golang locked and limited conversation to collaborators Mar 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.