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: OXDOT in walk when take the address of variable in generic type #49659

Closed
squareheadc opened this issue Nov 18, 2021 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@squareheadc
Copy link

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

$ go version
go version devel go1.18-f6647f2 Thu Nov 18 06:05:29 2021 +0000 darwin/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/squarehead/Library/Caches/go-build"
GOENV="/Users/squarehead/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/squarehead/Program/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/squarehead/Program/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/squarehead/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/squarehead/sdk/gotip/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.18-f6647f2 Thu Nov 18 06:05:29 2021 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/squarehead/Program/go/src/play/generic/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/28/rqpspsvd3ysgqk9bqth_tx1c0000gn/T/go-build2494623361=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

there are two packages like this:

package p2

type A[T any] struct {
	a int
}

func (a A[T]) F() {
	_ = &a.a
}
package p1

import "p2"

type B[T any] struct {
	a p2.A[T]
}

func (b B[T]) F() {
	b.a.F()
}

and build them

What did you expect to see?

What did you see instead?

# p1
./p2/p.go:8:8: internal compiler error: OXDOT in walk: p2.a.a

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/squarehead/sdk/gotip/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x22005b8?, 0x0?}, {0x191c8cb, 0x11}, {0xc0000ef1c0, 0x1, 0x1})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/base/print.go:227 +0x1ca
cmd/compile/internal/ir.OuterValue({0x1a8b320?, 0xc000424960?})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/node.go:587 +0x1f3
cmd/compile/internal/typecheck.ComputeAddrtaken.func1({0x1a88f30, 0xc00060da90})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/subr.go:114 +0x65
cmd/compile/internal/ir.Visit.func1({0x1a88f30, 0xc00060da90})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:105 +0x30
cmd/compile/internal/ir.(*AssignStmt).doChildren(0xc00060dae0, 0xc00000de18)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:152 +0x7c
cmd/compile/internal/ir.DoChildren(...)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:94
cmd/compile/internal/ir.Visit.func1({0x1a89250, 0xc00060dae0})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:106 +0x57
cmd/compile/internal/ir.Visit({0x1a89250, 0xc00060dae0}, 0xc00006cf60)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:108 +0xb8
cmd/compile/internal/typecheck.ComputeAddrtaken({0xc00006cf50?, 0x1, 0xa02000000002?})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/subr.go:127 +0xc5
cmd/compile/internal/typecheck.ImportedBody.func1()
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/func.go:163 +0x3a
cmd/compile/internal/typecheck.ImportedBody(0xc000378f20)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/func.go:199 +0x1b3
cmd/compile/internal/typecheck.(*crawler).markInlBody(0xc00000ddb8, 0xd4c71416aad6aa12?)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:219 +0x1ec
cmd/compile/internal/typecheck.(*crawler).markObject(0x18990e0?, 0xc000612270)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:39 +0x2f
cmd/compile/internal/typecheck.(*crawler).markGeneric(0xc00000ddb8, 0x5?)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:192 +0xe9
cmd/compile/internal/typecheck.(*crawler).markInlBody.func1({0x1a8b320, 0xc000424720})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:226 +0x78
cmd/compile/internal/ir.Visit.func1({0x1a8b320, 0xc000424720})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:105 +0x30
cmd/compile/internal/ir.(*SelectorExpr).doChildren(0xc000424780, 0xc00000dde8)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1095 +0x53
cmd/compile/internal/ir.DoChildren(...)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:94
cmd/compile/internal/ir.Visit.func1({0x1a8b320, 0xc000424780})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:106 +0x57
cmd/compile/internal/ir.(*CallExpr).doChildren(0xc00058ac60, 0xc00000dde8)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:260 +0x56
cmd/compile/internal/ir.DoChildren(...)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:94
cmd/compile/internal/ir.Visit.func1({0x1a89638, 0xc00058ac60})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:106 +0x57
cmd/compile/internal/ir.Visit({0x1a89638, 0xc00058ac60}, 0xc00000ddd0)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:108 +0xb8
cmd/compile/internal/ir.VisitList(...)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/ir/visit.go:114
cmd/compile/internal/typecheck.(*crawler).markInlBody(0xc00000ddb8, 0xb45979051db543ba?)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:276 +0x2f4
cmd/compile/internal/typecheck.(*crawler).markObject(0x18990e0?, 0xc000612b60)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:39 +0x2f
cmd/compile/internal/typecheck.(*crawler).markEmbed(0xc00000ddb8, 0x18c1180?)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:159 +0x16f
cmd/compile/internal/typecheck.(*crawler).markObject(0x10cd73e?, 0xc00037bad0)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:45 +0x4b
cmd/compile/internal/typecheck.crawlExports({0xc00000e530, 0x1, 0x10d1bcc?})
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/crawler.go:26 +0xbf
cmd/compile/internal/typecheck.WriteExports({0x1a83b00, 0xc00060e4e0}, 0x1)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/typecheck/iexport.go:305 +0x65
cmd/compile/internal/noder.WriteExports(0xc00006cee0)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/noder/export.go:40 +0x7a
cmd/compile/internal/gc.dumpCompilerObj(0xc00006cee0?)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/gc/obj.go:107 +0x28
cmd/compile/internal/gc.dumpobj1({0x7ff7bfeff355, 0x50}, 0x3)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/gc/obj.go:63 +0x17b
cmd/compile/internal/gc.dumpobj()
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/gc/obj.go:44 +0x36
cmd/compile/internal/gc.Main(0x1943ec0)
	/Users/squarehead/sdk/gotip/src/cmd/compile/internal/gc/main.go:335 +0x11fc
main.main()
	/Users/squarehead/sdk/gotip/src/cmd/compile/main.go:55 +0xdd
@ALTree ALTree changed the title internal compiler error: OXDOT in walk when take the address of variable in generic type cmd/compile: internal compiler error: OXDOT in walk when take the address of variable in generic type Nov 18, 2021
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 18, 2021
@ALTree ALTree added this to the Go1.18 milestone Nov 18, 2021
@danscales
Copy link
Contributor

I'm looking at this. We need to adjust ComputeAddrTaken processing a bit in the presence of imported generic functions and function instantiations.

@danscales danscales self-assigned this Nov 18, 2021
@gopherbot
Copy link

Change https://golang.org/cl/365214 mentions this issue: cmd/compile: don't run ComputeAddrTaken on imported generic functions

@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

4 participants