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: crash in type loop detection since CL 258177 #42075

Closed
mvdan opened this issue Oct 19, 2020 · 2 comments
Closed

cmd/compile: crash in type loop detection since CL 258177 #42075

mvdan opened this issue Oct 19, 2020 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Oct 19, 2020

$ cat crash.go
package hamt

type T1 struct {
	x int
	f T2
}

type T2 struct {
	f T1
}
$ go1 version
go version go1.15.3 linux/amd64
$ go1 build crash.go
# command-line-arguments
./crash.go:8:6: invalid recursive type T2
$ go version
go version devel +c8f6135d4f Sat Oct 17 07:18:20 2020 +0000 linux/amd64
$ go build crash.go
# command-line-arguments
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa139b2]

goroutine 1 [running]:
cmd/compile/internal/gc.findTypeLoop(0xc0003a86c0, 0xc00010e850, 0xc000052ab0)
	/home/mvdan/tip/src/cmd/compile/internal/gc/align.go:202 +0xd2
cmd/compile/internal/gc.findTypeLoop(0xc0003e3500, 0xc00010e850, 0x1)
	/home/mvdan/tip/src/cmd/compile/internal/gc/align.go:216 +0x2b9
cmd/compile/internal/gc.findTypeLoop(0xc0003e34a0, 0xc00010e850, 0xc00000e3f8)
	/home/mvdan/tip/src/cmd/compile/internal/gc/align.go:202 +0xe7
cmd/compile/internal/gc.findTypeLoop(0xc0003e35c0, 0xc00010e850, 0x0)
	/home/mvdan/tip/src/cmd/compile/internal/gc/align.go:216 +0x2b9
[...]

Note that the crash does not happen if I remove x int. This is a minified version of a real crash I encountered while generating Go code with type loops (by mistake).

I tried to figure out a quick fix, but couldn't really. cc @mdempsky @cuonglm

@mvdan mvdan added this to the Go1.16 milestone Oct 19, 2020
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 19, 2020
@cagedmantis
Copy link
Contributor

/cc @randall77 @griesemer

@mdempsky mdempsky self-assigned this Oct 19, 2020
@gopherbot
Copy link

Change https://golang.org/cl/263717 mentions this issue: cmd/compile: fix reporting of invalid recursive types

@golang golang locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants