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,types2: Stack overflow when type parameter and constraint names are the same #51496

Closed
dtcaciuc opened this issue Mar 5, 2022 · 2 comments

Comments

@dtcaciuc
Copy link
Contributor

dtcaciuc commented Mar 5, 2022

What version of Go are you using (go version)?

$ go version
go version go1.18beta1 linux/amd64

Does this issue reproduce with the latest release?

No

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOHOSTARCH="amd64"
GOHOSTOS="linux"

What did you do?

Run go run main.go with the following contents:

package main

type Job interface{}

type Handler[Job Job] struct {}

What did you expect to see?

An error announcing invalid type parameter declaration (?)

What did you see instead?

# command-line-arguments
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020460380 stack=[0xc020460000, 0xc040460000]
fatal error: stack overflow

runtime stack:
runtime.throw({0xd20a11?, 0x12e92c0?})
        /usr/local/go/src/runtime/panic.go:992 +0x71
runtime.newstack()
        /usr/local/go/src/runtime/stack.go:1101 +0x5cc
runtime.morestack()
        /usr/local/go/src/runtime/asm_amd64.s:547 +0x8b

goroutine 1 [running]:
cmd/compile/internal/types2.under({0xe8d180?, 0xc0003d93b0?})
        /usr/local/go/src/cmd/compile/internal/types2/type.go:23 +0x71 fp=0xc020460390 sp=0xc020460388 pc=0xb94451
cmd/compile/internal/types2.(*TypeParam).iface(0xc0003d93b0)
        /usr/local/go/src/cmd/compile/internal/types2/typeparam.go:104 +0x37 fp=0xc0204603e8 sp=0xc020460390 pc=0xb95077
cmd/compile/internal/types2.(*TypeParam).Underlying(0x0?)

...

cmd/compile/internal/types2.(*TypeParam).Underlying(0x0?)
        /usr/local/go/src/cmd/compile/internal/types2/typeparam.go:88 +0x19 fp=0xc0204e1500 sp=0xc0204e14e8 pc=0xb94fb9
cmd/compile/internal/types2.under({0xe8d180?, 0xc00045b290?})
        /usr/local/go/src/cmd/compile/internal/types2/type.go:27 +0x58 fp=0xc0204e1518 sp=0xc0204e1500 pc=0xb94438
...additional frames elided...
@dominikh
Copy link
Member

dominikh commented Mar 5, 2022

This seems to have been fixed on master:

./baz.go:5:18: cannot use a type parameter as constraint

@dominikh
Copy link
Member

dominikh commented Mar 5, 2022

Specifically this was fixed by 7a3a2b1.

@dominikh dominikh closed this as completed Mar 5, 2022
@golang golang locked and limited conversation to collaborators Mar 5, 2023
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

3 participants