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: potentially nil pointer dereference panic #15717

Closed
wheelcomplex opened this issue May 17, 2016 · 4 comments
Closed

cmd/api: potentially nil pointer dereference panic #15717

wheelcomplex opened this issue May 17, 2016 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@wheelcomplex
Copy link
Contributor

wheelcomplex commented May 17, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version devel +495e3c6 Tue May 17 04:02:11 2016 +0000 freebsd/amd64
    
  2. What operating system and processor architecture are you using (go env)?
    N/A
    
  3. What did you do?

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

  1. What did you expect to see?

Check return value befor use it.

  1. What did you see instead?

Hit this panic in my private Go hacking stuff.

@gopherbot
Copy link

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

@bradfitz
Copy link
Contributor

How did you hit this? Are you writing code in your $GOROOT instead of your $GOPATH?

@bradfitz bradfitz added this to the Unplanned milestone May 17, 2016
@bradfitz bradfitz added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 17, 2016
@wheelcomplex
Copy link
Contributor Author

wheelcomplex commented May 18, 2016

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.

@bradfitz
Copy link
Contributor

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

@golang golang locked and limited conversation to collaborators May 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants