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: "internal compiler error: mayCall" in method of parameterized type #47924

Closed
jayconrod opened this issue Aug 23, 2021 · 4 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jayconrod
Copy link
Contributor

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

$ go version
go version devel go1.18-8486ced8b0 Mon Aug 23 17:51:41 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

n/a

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jay/.cache/go-build"
GOENV="/home/jay/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jay/.cache/gomodcache"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jay/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/jay/Code/goroot"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jay/Code/goroot/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-8486ced8b0 Mon Aug 23 17:51:41 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jay/Code/goroot/src/cmd/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4153403543=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  • Added type parameters to cmd/go/internal/work.Cache. See CL 344513, PS1.
  • Ran go test cmd/go/internal/par.

What did you expect to see?

Tests pass

What did you see instead?

# cmd/go/internal/par [cmd/go/internal/par.test]
internal/par/cache.go:92:14: internal compiler error: mayCall 
.   DYNAMICDOTTYPE tc(1) .shape.int # cache.go:92:14 .shape.int
.   .   NAME-par.key esc(no) tc(1) Class:PPARAM Offset:0 OnStack INTER-interface {} # cache.go:91:17
.   DYNAMICDOTTYPE-T
.   .   INDEX tc(1) Bounded PTR-*uint8 # cache.go:92:14 PTR-*uint8
.   .   .   DEREF tc(1) ARRAY-[5]uintptr # cache.go:92:14 ARRAY-[5]uintptr
.   .   .   .   CONVNOP tc(1) PTR-*[5]uintptr # cache.go:92:14 PTR-*[5]uintptr
.   .   .   .   .   CONVNOP tc(1) UNSAFEPTR-unsafe.Pointer # cache.go:92:14 UNSAFEPTR-unsafe.Pointer
.   .   .   .   .   .   NAME-par..dict esc(no) tc(1) Class:PAUTO Offset:0 OnStack uintptr # cache.go:91:12
.   .   .   LITERAL-0 tc(1) uintptr # cache.go:91:12

goroutine 1 [running]:
runtime/debug.Stack()
        /home/jay/Code/goroot/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x9eede0, 0xc0}, {0xcefdb7, 0xb}, {0xc0000b90d0, 0x1, 0x1})
        /home/jay/Code/goroot/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/walk.mayCall.func2({0xe61e68, 0xc0009eede0})
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/walk.go:308 +0x3c9
cmd/compile/internal/ir.Any.func1({0xe61e68, 0xc0009eede0})
        /home/jay/Code/goroot/src/cmd/compile/internal/ir/visit.go:130 +0x30
cmd/compile/internal/ir.Any({0xe61e68, 0xc0009eede0}, 0xc00078f9e0)
        /home/jay/Code/goroot/src/cmd/compile/internal/ir/visit.go:132 +0xb8
cmd/compile/internal/walk.mayCall({0xe61e68, 0xc0009eede0})
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/walk.go:299 +0x73
cmd/compile/internal/walk.walkCall1(0xc0009dd4d0, 0xc0000b9828)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/expr.go:583 +0x2f8
cmd/compile/internal/walk.walkCall(0xc0009dd4d0, 0x2)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/expr.go:553 +0x6b2
cmd/compile/internal/walk.walkExpr1({0xe61698, 0xc0009dd4d0}, 0xc0009dd4d0)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/expr.go:176 +0x485
cmd/compile/internal/walk.walkExpr({0xe61698, 0xc0009dd4d0}, 0xc0000b9828)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/expr.go:55 +0x428
cmd/compile/internal/walk.walkAssign(0xc0000b9828, {0xe612b0, 0xc00037f9f0})
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/assign.go:72 +0x9dc
cmd/compile/internal/walk.walkExpr1({0xe612b0, 0xc00037f9f0}, 0xc00037f9f0)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/expr.go:179 +0x43f
cmd/compile/internal/walk.walkExpr({0xe612b0, 0xc00037f9f0}, 0xc0000b9828)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/expr.go:55 +0x428
cmd/compile/internal/walk.walkStmt({0xe612b0, 0xc00037f9f0})
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/stmt.go:57 +0x5da
cmd/compile/internal/walk.walkStmtList({0xc00078f980, 0x1, 0xc00037fa40})
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/stmt.go:167 +0x5b
cmd/compile/internal/walk.walkExpr({0xe61c10, 0xc00037fa40}, 0xc0009f4470)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/expr.go:37 +0xef
cmd/compile/internal/walk.walkIf(0xc0009f4460)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/stmt.go:219 +0x31
cmd/compile/internal/walk.walkStmt({0xe62318, 0xc0009f4460})
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/stmt.go:131 +0x2fc
cmd/compile/internal/walk.walkStmtList({0xc00042c940, 0x3, 0xc0009c74a0})
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/stmt.go:167 +0x5b
cmd/compile/internal/walk.Walk(0xc0009c74a0)
        /home/jay/Code/goroot/src/cmd/compile/internal/walk/walk.go:43 +0xef
cmd/compile/internal/gc.prepareFunc(0xc0009c74a0)
        /home/jay/Code/goroot/src/cmd/compile/internal/gc/compile.go:92 +0x6d
cmd/compile/internal/gc.enqueueFunc(0xc0009c7340)
        /home/jay/Code/goroot/src/cmd/compile/internal/gc/compile.go:66 +0x2f7
cmd/compile/internal/gc.Main(0xd1bee0)
        /home/jay/Code/goroot/src/cmd/compile/internal/gc/main.go:296 +0xe77
main.main()
        /home/jay/Code/goroot/src/cmd/compile/main.go:55 +0xdd

FAIL    cmd/go/internal/par [build failed]
FAIL
@jayconrod jayconrod added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 23, 2021
@jayconrod jayconrod added this to the Go1.18 milestone Aug 23, 2021
@griesemer
Copy link
Contributor

Simpler reproducer. Compiling

package p

import "sync"

type Cache[K, V any] struct {
	m sync.Map
}

func (c *Cache[K, V]) foo(x interface{}, f func(K) bool) {
	f(x.(K))
}

var _ Cache[int, int]

produces:

$ go tool compile x.go2
x.go2:10:5: internal compiler error: mayCall 
.   DYNAMICDOTTYPE tc(1) .shape.int # x.go2:10:5 .shape.int
.   .   NAME-p.x esc(no) tc(1) Class:PPARAM Offset:0 OnStack INTER-interface {} # x.go2:9:27
.   DYNAMICDOTTYPE-T
.   .   INDEX tc(1) Bounded PTR-*uint8 # x.go2:10:5 PTR-*uint8
.   .   .   DEREF tc(1) ARRAY-[4]uintptr # x.go2:10:5 ARRAY-[4]uintptr
.   .   .   .   CONVNOP tc(1) PTR-*[4]uintptr # x.go2:10:5 PTR-*[4]uintptr
.   .   .   .   .   CONVNOP tc(1) UNSAFEPTR-unsafe.Pointer # x.go2:10:5 UNSAFEPTR-unsafe.Pointer
.   .   .   .   .   .   NAME-p..dict esc(no) tc(1) Class:PPARAM Offset:0 OnStack uintptr # x.go2:9:6
.   .   .   LITERAL-0 tc(1) uintptr # x.go2:9:6

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/gri/goroot/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x430900, 0xc0}, {0x18ed445, 0xb}, {0xc0004295b8, 0x1, 0x1})
	/Users/gri/goroot/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/walk.mayCall.func2({0x1a5f428, 0xc000430900})
	/Users/gri/goroot/src/cmd/compile/internal/walk/walk.go:308 +0x3c9
cmd/compile/internal/ir.Any.func1({0x1a5f428, 0xc000430900})
	/Users/gri/goroot/src/cmd/compile/internal/ir/visit.go:130 +0x30
cmd/compile/internal/ir.Any({0x1a5f428, 0xc000430900}, 0xc000061890)
	/Users/gri/goroot/src/cmd/compile/internal/ir/visit.go:132 +0xb8
cmd/compile/internal/walk.mayCall({0x1a5f428, 0xc000430900})
	/Users/gri/goroot/src/cmd/compile/internal/walk/walk.go:299 +0x73
cmd/compile/internal/walk.walkCall1(0xc00044c120, 0xc000429a80)
	/Users/gri/goroot/src/cmd/compile/internal/walk/expr.go:583 +0x2f8
cmd/compile/internal/walk.walkCall(0xc00044c120, 0x0)
	/Users/gri/goroot/src/cmd/compile/internal/walk/expr.go:553 +0x6b2
cmd/compile/internal/walk.walkExpr1({0x1a5ec58, 0xc00044c120}, 0xc00044c120)
	/Users/gri/goroot/src/cmd/compile/internal/walk/expr.go:176 +0x485
cmd/compile/internal/walk.walkExpr({0x1a5ec58, 0xc00044c120}, 0xc000429a80)
	/Users/gri/goroot/src/cmd/compile/internal/walk/expr.go:55 +0x428
cmd/compile/internal/walk.walkStmt({0x1a5ec58, 0xc00044c120})
	/Users/gri/goroot/src/cmd/compile/internal/walk/stmt.go:57 +0x5da
cmd/compile/internal/walk.walkStmtList({0xc000061880, 0x1, 0xc000444b00})
	/Users/gri/goroot/src/cmd/compile/internal/walk/stmt.go:167 +0x5b
cmd/compile/internal/walk.Walk(0xc000444b00)
	/Users/gri/goroot/src/cmd/compile/internal/walk/walk.go:43 +0xef
cmd/compile/internal/gc.prepareFunc(0xc000444b00)
	/Users/gri/goroot/src/cmd/compile/internal/gc/compile.go:92 +0x6d
cmd/compile/internal/gc.enqueueFunc(0xc000444b00)
	/Users/gri/goroot/src/cmd/compile/internal/gc/compile.go:66 +0x2f7
cmd/compile/internal/gc.Main(0x1919338)
	/Users/gri/goroot/src/cmd/compile/internal/gc/main.go:296 +0xe77
main.main()
	/Users/gri/goroot/src/cmd/compile/main.go:55 +0xdd

@griesemer griesemer changed the title cmd/compile: "internal compiler error: mayCall" when testing parameterized package cmd/compile: "internal compiler error: mayCall" in method of parameterized type Aug 23, 2021
@griesemer
Copy link
Contributor

griesemer commented Aug 23, 2021

Even simpler reproducer:

package p

type Cache[K any] struct {}

func (c Cache[K]) foo(x interface{}, f func(K) bool) {
	f(x.(K))
}

var _ Cache[int]

For reference, this version compiles fine:

package p

func foo[K any](x interface{}, f func(K) bool) {
	f(x.(K))
}

@danscales
Copy link
Contributor

@randall77 Do you want to look at this, since it involves DYNAMICDOTTYPE? Seems like we probably just add DYNAMICDOTTYPE in with the case with DOTTYPE in function walk.go:mayCall(), since DYNAMICDOTTYPE can also panic, like all the other ops in that case.

@randall77 randall77 assigned randall77 and unassigned danscales Aug 24, 2021
@gopherbot
Copy link

Change https://golang.org/cl/344571 mentions this issue: cmd/compile: mark ODYNAMICDOTTYPE as an expression that can panic

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants