Skip to content

gofmt: panic: runtime error: invalid memory address or nil pointer dereference #1028

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

Closed
gopherbot opened this issue Aug 14, 2010 · 6 comments

Comments

@gopherbot
Copy link
Contributor

by tianyicui:

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. $ gofmt -r="α.Data() -> *α" main.go
(the related file main.go is attached)

What is the expected output?

I want to change things from "range self.pkgs.Data()" to "range
*self.pkgs" (self.pkgs is vector.StringVector). I'm not sure if I fully understand
the usage of -r flag of gofmt, but at least it should not end with a panic.

What do you see instead?

panic: runtime error: invalid memory address or nil pointer dereference

panic PC=0x3344f0
runtime.panic+0xb2 /Users/tianyi/OSS/go/src/pkg/runtime/proc.c:1015
    runtime.panic(0x0, 0x3226e8)
panicstring+0x69 /Users/tianyi/OSS/go/src/pkg/runtime/runtime.c:83
    panicstring(0x8ee70, 0x344a60)
sigpanic+0x148 /Users/tianyi/OSS/go/src/pkg/runtime/darwin/thread.c:460
    sigpanic()
reflect.*PtrValue·PointTo+0x27 /Users/tianyi/OSS/go/src/pkg/reflect/value.go:1062
    reflect.*PtrValue·PointTo(0x0, 0x4fa09, 0x351be0, 0xb7e01)
main.subst+0x338 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:227
    main.subst(0x351c00, 0x0, 0x0, 0x0, 0x0, ...)
main.subst+0x5e9 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:221
    main.subst(0x0, 0x346cc0, 0x351be0, 0x0, 0x0, ...)
main.subst+0x31c /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:227
    main.subst(0x0, 0x346d20, 0x3519c0, 0x0, 0x0, ...)
main.subst+0x446 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:232
    main.subst(0x0, 0x346cc0, 0x351980, 0x0, 0x0, ...)
main.subst+0x5e9 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:221
    main.subst(0x0, 0x346de0, 0x351940, 0x0, 0x0, ...)
main.subst+0x31c /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:227
    main.subst(0x0, 0x346d20, 0x3518c0, 0x0, 0x0, ...)
main.subst+0x178 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:200
    main.subst(0x0, 0x346cc0, 0x351600, 0x0, 0x0, ...)
main.subst+0x446 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:232
    main.subst(0x312d20, 0x346cc0, 0x351880, 0x346d20, 0x351760, ...)
main.subst+0x5e9 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:221
    main.subst(0x312d20, 0x346de0, 0x351840, 0x346d20, 0x351760, ...)
main.subst+0x31c /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:227
    main.subst(0x312d20, 0x346d20, 0x3517a0, 0x346d20, 0x351760, ...)
main._func_003+0x20d /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:61
    main._func_003(0x312d20, 0x346cc0, 0x315c60, 0x346d20, 0x351760, ...)
main.apply+0x10b /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:98
    main.apply(0x346cc0, 0x338ce0, 0x338ce0, 0x338cc0, 0x338c01, ...)
main._func_003+0xea /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:59
    main._func_003(0x34c4b0, 0x346de0, 0x338cc0, 0x0, 0x89bb8, ...)
main.apply+0x1f4 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:94
    main.apply(0x346de0, 0x338cc0, 0x346de0, 0x338cc0, 0x1, ...)
main._func_003+0xea /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:59
    main._func_003(0x34c4b0, 0x346cc0, 0x3388a0, 0x353208, 0x1, ...)
main.apply+0x10b /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:98
    main.apply(0x346cc0, 0x3388a0, 0x3388a0, 0x338880, 0x338801, ...)
main._func_003+0xea /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:59
    main._func_003(0x34c4b0, 0x346de0, 0x338880, 0xb9240, 0x34d700, ...)
main.apply+0x2cf /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:89
    main.apply(0x346de0, 0x338880, 0x346de0, 0x338880, 0x338201, ...)
main._func_003+0xea /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:59
    main._func_003(0x34c4b0, 0x346d80, 0x338280, 0x0, 0x77090, ...)
main.apply+0x1f4 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:94
    main.apply(0x346d80, 0x338280, 0x346d80, 0x338280, 0x338101, ...)
main._func_003+0xea /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:59
    main._func_003(0x34c4b0, 0x346cc0, 0x3381a0, 0x0, 0x6ef38, ...)
main.apply+0x1f4 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:94
    main.apply(0x346cc0, 0x3381a0, 0x346cc0, 0x3381a0, 0x1, ...)
main._func_003+0xea /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:59
    main._func_003(0x34c4b0, 0x346cc0, 0x33f260, 0x349a80, 0x1, ...)
main.apply+0x10b /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:98
    main.apply(0x346cc0, 0x33f260, 0x33f260, 0x33f240, 0x33f201, ...)
main._func_003+0xea /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:59
    main._func_003(0x34c4b0, 0x346de0, 0x33f240, 0xb5240, 0x34d700, ...)
main.apply+0x2cf /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:89
    main.apply(0x346de0, 0x33f240, 0x346de0, 0x33f240, 0x350001, ...)
main._func_003+0xea /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:59
    main._func_003(0x34c4b0, 0x346d80, 0x350080, 0x0, 0x72278, ...)
main.apply+0x1f4 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:94
    main.apply(0x346d80, 0x350080, 0x346d80, 0x350080, 0x303d01, ...)
main.rewriteFile+0x1a5 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:65
    main.rewriteFile(0x34c4b0, 0x346cc0, 0x315c80, 0x315c80, 0x34e130, ...)
main._func_002+0x41 /Users/tianyi/OSS/go/src/cmd/gofmt/rewrite.go:31
    main._func_002(0x300540, 0x323ba0, 0x3004e0, 0x300510, 0x34c460, ...)
main.processFile+0x151 /Users/tianyi/OSS/go/src/cmd/gofmt/gofmt.go:101
    main.processFile(0x34c460, 0x7, 0xb2040, 0x332190)
main.processFileByName+0xa8 /Users/tianyi/OSS/go/src/cmd/gofmt/gofmt.go:137
    main.processFileByName(0x3004b0, 0x7, 0x0, 0x3004b0, 0x0, ...)
main.main+0x226 /Users/tianyi/OSS/go/src/cmd/gofmt/gofmt.go:201
    main.main()
mainstart+0xf /Users/tianyi/OSS/go/src/pkg/runtime/amd64/asm.s:78
    mainstart()
goexit /Users/tianyi/OSS/go/src/pkg/runtime/proc.c:145
    goexit()

What is your $GOOS?  $GOARCH?

GOOS=darwin
GOARCH=amd64

Which revision are you using?  (hg identify)

843a555976df


Please provide any additional information below.

Attachments:

  1. main.go (5072 bytes)
@adg
Copy link
Contributor

adg commented Aug 16, 2010

Comment 1:

It works for me at f78fafa04768+ tip.
Can you hg sync, run all.bash, and try again?

Status changed to WaitingForReply.

@gopherbot
Copy link
Contributor Author

Comment 2 by tianyicui:

I hg-pulled "f78fafa04768+ tip", run all.bash, and got exactly the same output. What can
I do to help?

@griesemer
Copy link
Contributor

Comment 3:

Owner changed to [email protected].

Status changed to Accepted.

@griesemer
Copy link
Contributor

Comment 4:

The following program reproduces the crash:
package P
var _ = x.Data()

@griesemer
Copy link
Contributor

Comment 5:

Several issues:
./gofmt -r="x -> x" test.go
panic: interface conversion: *ast.CommentGroup is not ast.Node: missing method Pos
package P
var _ = x
./gofmt -r="-x -> x" test.go
panic: runtime error: invalid memory address or nil pointer dereference
package P
var _ = -x

@griesemer
Copy link
Contributor

Comment 6:

This issue was closed by revision a48b35e.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

3 participants