Closed
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go version go1.10rc2 linux/amd64
What did you do?
package main
type I = interface {
I2
}
type I2 interface {
I
}
func main() {
}
What did you expect to see?
Compiler doesn't crash. An error message should be printed.
What did you see instead?
Compiler crashes.
# command-line-arguments
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x9fec2c]
goroutine 1 [running]:
...
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
mvdan commentedon Feb 14, 2018
Slightly smaller repro:
If one removes the
=
, the compiler properly detects the recursive type and errors. It seems like it doesn't when a type alias is involved.[-]cmd/compile: compiler crashes on loop interface embedding[/-][+]cmd/compile: compiler crashes on interface embedding cycles if a type alias is used[/+][-]cmd/compile: compiler crashes on interface embedding cycles if a type alias is used[/-][+]cmd/compile: crash on interface embedding cycles if a type alias is used[/+]gopherbot commentedon Feb 14, 2018
Change https://golang.org/cl/93955 mentions this issue:
cmd/compile: fix crash on interface alias cycle
mvdan commentedon Mar 4, 2018
This is turning out to be a subtle bug in the compiler, and I've spent enough hours failing to find the fix. I'll let someone else (@mdempsky?) take over.
As a piece of perhaps useful information, if you replace the interface types with structs, there is no crash. So the bug involves both aliases and interfaces - if either of them is removed, the bug disappears.
griesemer commentedon Jun 5, 2018
Possibly related to #18640.
gopherbot commentedon Jun 12, 2018
Change https://golang.org/cl/118078 mentions this issue:
cmd/compile: correct alias cycle detection
cmd/compile: correct alias cycle detection
20 remaining items