Skip to content

cmd/compile: crash on interface embedding cycles if a type alias is used #23823

Closed
@zigo101

Description

@zigo101

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]:
...

Activity

mvdan

mvdan commented on Feb 14, 2018

@mvdan
Member

Slightly smaller repro:

package p

type I = interface {
        I2
}

type I2 interface {
        I
}

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.

added this to the Go1.11 milestone on Feb 14, 2018
added
NeedsFixThe path to resolution is known, but the work has not been done.
on Feb 14, 2018
changed the title [-]cmd/compile: compiler crashes on loop interface embedding[/-] [+]cmd/compile: compiler crashes on interface embedding cycles if a type alias is used[/+] on Feb 14, 2018
changed the title [-]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[/+] on Feb 14, 2018
self-assigned this
on Feb 14, 2018
gopherbot

gopherbot commented on Feb 14, 2018

@gopherbot
Contributor

Change https://golang.org/cl/93955 mentions this issue: cmd/compile: fix crash on interface alias cycle

removed their assignment
on Mar 4, 2018
mvdan

mvdan commented on Mar 4, 2018

@mvdan
Member

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.

self-assigned this
on Jun 5, 2018
griesemer

griesemer commented on Jun 5, 2018

@griesemer
Contributor

Possibly related to #18640.

gopherbot

gopherbot commented on Jun 12, 2018

@gopherbot
Contributor

Change https://golang.org/cl/118078 mentions this issue: cmd/compile: correct alias cycle detection

20 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mvdan@griesemer@gopherbot@zigo101

        Issue actions

          cmd/compile: crash on interface embedding cycles if a type alias is used · Issue #23823 · golang/go