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: potentially nil pointer dereference panic #15717
Comments
CL https://golang.org/cl/23128 mentions this issue. |
How did you hit this? Are you writing code in your $GOROOT instead of your $GOPATH? |
Yes, I'm coding in $GOROOT for learning(development of Go Programming Language). To hit this, apply follow patch to tip and run ./all.bash(in a FreeBSD machine): diff -Nru tips-go/src/go/build/deps_test.go precontribute-go/src/go/build/deps_test.go --- tips-go/src/go/build/deps_test.go 2016-05-17 17:19:29.756772000 +0800 +++ precontribute-go/src/go/build/deps_test.go 2016-05-18 09:50:56.893770000 +0800 @@ -395,6 +395,8 @@ "net/http/pprof": {"L4", "OS", "html/template", "net/http", "runtime/pprof", "runtime/trace"}, "net/rpc": {"L4", "NET", "encoding/gob", "html/template", "net/http"}, "net/rpc/jsonrpc": {"L4", "NET", "encoding/json", "net/rpc"}, + "goapitest": {"strconv"}, + "goapitest/subpkg": {"strconv"}, } // isMacro reports whether p is a package dependency macro diff -Nru tips-go/src/goapitest/goapitest.go precontribute-go/src/goapitest/goapitest.go --- tips-go/src/goapitest/goapitest.go 1970-01-01 08:00:00.000000000 +0800 +++ precontribute-go/src/goapitest/goapitest.go 2016-05-18 10:12:17.667205000 +0800 @@ -0,0 +1,12 @@ +// +build s390x + +// test code for https://github.com/golang/go/issues/15717 +package goapitest + +import "strconv" + +type Test int + +func (t *Test) String() string { + return strconv.Itoa(int(*t)) +} diff -Nru tips-go/src/goapitest/subpkg/subpkg.go precontribute-go/src/goapitest/subpkg/subpkg.go --- tips-go/src/goapitest/subpkg/subpkg.go 1970-01-01 08:00:00.000000000 +0800 +++ precontribute-go/src/goapitest/subpkg/subpkg.go 2016-05-18 10:12:19.481340000 +0800 @@ -0,0 +1,12 @@ +// +build freebsd + +// test code for https://github.com/golang/go/issues/15717 +package subpkg + +import "strconv" + +type TestSub int + +func (t *TestSub) String() string { + return strconv.Itoa(int(*t)) +} In Linux machine change subpkg to // +build linux. |
Sorry, this isn't a bug. You shouldn't be hacking in $GOROOT and expect everything following $GOROOT's rules to work. Please hack in $GOPATH instead. See https://golang.org/doc/code.html |
Please answer these questions before submitting your issue. Thanks!
go version
)?go env
)?In the end of ./all.bash, goapi walk through all package directorys and meet "_build.NoGoError" error, func *Walker.Import return "nil, nil" as "_types.Package, error", and the returned *types.Package(nil) used at func main without nil check.
func *Walker.Import at https://github.com/golang/go/blob/master/src/cmd/api/goapi.go#L459
func main at https://github.com/golang/go/blob/master/src/cmd/api/goapi.go#L160
Check return value befor use it.
Hit this panic in my private Go hacking stuff.
The text was updated successfully, but these errors were encountered: