Skip to content

cmd/compile,types2: Stack overflow when type parameter and constraint names are the same #51496

@dtcaciuc

Description

@dtcaciuc

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions