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/compile: nil pointer defer in outervalue #13265

Closed
dvyukov opened this issue Nov 16, 2015 · 4 comments
Closed

cmd/compile: nil pointer defer in outervalue #13265

dvyukov opened this issue Nov 16, 2015 · 4 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Nov 16, 2015

Reproducer:
https://gist.githubusercontent.com/dvyukov/20774908b7ea4e70a16d/raw/b0df0a7818189971dd47daa7d93fdc5b215decf4/test.go

$ go build -race gogo.go

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x78 pc=0x653771]

goroutine 1 [running]:
cmd/compile/internal/gc.outervalue(0x0, 0xc82034bd80)
    src/cmd/compile/internal/gc/walk.go:2345 +0x21
cmd/compile/internal/gc.iscallret(0x0, 0xc820359ef0)
    src/cmd/compile/internal/gc/walk.go:2034 +0x21
cmd/compile/internal/gc.instrumentnode(0xc8203e1518, 0xc8203e1520, 0x0, 0x0)
    src/cmd/compile/internal/gc/racewalk.go:161 +0x14f1
cmd/compile/internal/gc.instrumentnode(0xc8201e9cb8, 0xc820355060, 0x0, 0x0)
    src/cmd/compile/internal/gc/racewalk.go:128 +0x15f
cmd/compile/internal/gc.instrumentnode(0xc82034a9e0, 0xc8203e1680, 0x0, 0x0)
    src/cmd/compile/internal/gc/racewalk.go:385 +0x1796
cmd/compile/internal/gc.instrumentlist(0xc82034a9e0, 0x0)
    src/cmd/compile/internal/gc/racewalk.go:94 +0x6e
cmd/compile/internal/gc.instrument(0xc8201e5830)
    src/cmd/compile/internal/gc/racewalk.go:58 +0x829
cmd/compile/internal/gc.compile(0xc8201e5830)
    src/cmd/compile/internal/gc/pgen.go:403 +0x5d4
cmd/compile/internal/gc.funccompile(0xc8201e5830)
    src/cmd/compile/internal/gc/dcl.go:1448 +0x1c0
cmd/compile/internal/gc.Main()
    src/cmd/compile/internal/gc/lex.go:487 +0x2150
cmd/compile/internal/amd64.Main()
    src/cmd/compile/internal/amd64/galign.go:127 +0x58d
main.main()
    src/cmd/compile/main.go:27 +0x36f

go version devel +25a28da Sun Nov 15 23:41:28 2015 +0000 linux/amd64

@dvyukov
Copy link
Member Author

dvyukov commented Nov 16, 2015

@rsc @griesemer

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Nov 16, 2015
@griesemer
Copy link
Contributor

This is unrelated to the new parser code. The bug also appears with:
go build -gcflags=-oldparser -race foo.go

@rsc rsc modified the milestones: Unplanned, Go1.6 Dec 5, 2015
@gopherbot
Copy link

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

@JayNakrani
Copy link
Contributor

JayNakrani commented Jan 8, 2017

ls[i].Right is nil at line #157. That's causing iscallret() to pass nil to outervalue().

From what I understand, instrumentnode() is trying to determine whether an OAS node after function call was copying results off stack. But it appears from the dump (obtained with JayNakrani@c5f8b0b), that there can be autotmp OAS nodes with Right set to nil just after CALLFUNC. If it's okay for an OAS node to have nil Right, then fix is simple: golang.org/cl/34929

I also tried to isolate the problem in the source code, and it's the for loop's third assignment in main(). i.e the following snippet,

for ; false; Var1, Var342, (*(((<-Var343)[(<-((*(Var393))[(((make([][0]int, 0, 1))[(*(*(([]**int{})[(*((Var406)[Var476]))-(1)])))+(1)])[(<-make(chan int, 1))])+(1)])[(*(([]*int{})[(<-make(chan int))]))+(1)])])[(int)((Var667)[((func(chan string, uint) int)(nil))(make(chan string), uint(1))])])) = false, ((func(bool, int, rune, int16) (chan complex128, chan complex64, []int))(nil)), (*[]interface{})(nil) {
}

@golang golang locked and limited conversation to collaborators Oct 18, 2018
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

6 participants