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

compiler crash on recursive interface #2745

Closed
ianlancetaylor opened this issue Jan 20, 2012 · 6 comments
Closed

compiler crash on recursive interface #2745

ianlancetaylor opened this issue Jan 20, 2012 · 6 comments
Milestone

Comments

@ianlancetaylor
Copy link
Member

If I compile the appended with 6g, I get a segmentation fault.

package p

type I1 interface {
       F() interface{I1}
}

type I2 interface {
       F() interface{I2}
}   

var v1 I1
var v2 I2

func f() bool {
    return v1 == v2
}
@rsc
Copy link
Contributor

rsc commented Jan 20, 2012

Comment 1:

lvd has a fix nearly ready

Owner changed to @lvdlvd.

@lvdlvd
Copy link

lvdlvd commented Jan 20, 2012

Comment 2:

no thats in and probably caused this. im travelling today but will look
into this asap. /L

@rsc
Copy link
Contributor

rsc commented Jan 20, 2012

Comment 3:

I ran this on a very old copy of the compiler
and it still faults.  This is an infinite recursion
in eqtype.  Not sure it is worth fixing for Go 1
but will leave as Priority-Go1 for now.

Status changed to Accepted.

@ianlancetaylor
Copy link
Member Author

Comment 4:

We can't fix everything but I think that for the compiler any actual crash should be
addressed sooner rather than later.  I would be fine with printing an error for this
kind of code.
In gccgo this code crashed because of an infinite recursion in some code trying to
decide whether the types were the same.  I guess that is the gccgo equivalent to eqtype.
 I fixed it by passing down a list of types "assumed to be equivalent."  I just built
the list on the stack as I went.  Then when I start comparing two interface types, I
first check the list; if both types are on it, return true.  This shuts down the
infinite recursion and treats the types as equal if nothing indicates otherwise.

@rsc
Copy link
Contributor

rsc commented Jan 20, 2012

Comment 5:

Nice fix.

Owner changed to @rsc.

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Jan 23, 2012

Comment 6:

This issue was closed by revision 427b5bd.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
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

4 participants