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: testing with -race emits internal compiler error #53519

Closed
tbhartman opened this issue Jun 23, 2022 · 3 comments
Closed

cmd/compile: testing with -race emits internal compiler error #53519

tbhartman opened this issue Jun 23, 2022 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@tbhartman
Copy link

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

$ go version
go version go1.18 windows/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\XXX\AppData\Local\go-build
set GOENV=C:\Users\XXX\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\XXX\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\XXX\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\XXX\sdk\go1.18
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\XXX\sdk\go1.18\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\users\XXX\src\myProgram\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=D:\temp\go-build3139700636=/tmp/go-build -gno-record-gcc-switches

What did you do?

Admittedly, this is difficult for me to reproduce outside of my specific
environment. Especially, if I move these three files out of my module's
directory to a new module, I cannot reproduce the error.

I am very willing for this to be closed without further review, but given the
time I've invested, at least wanted to publish my findings.

From a project of mine with many files, I have distilled to a minimum working
example shown below:

go.mod
module example.com/myprog

go 1.18
main.go
package main

type MyInterface interface{}

type A[T any] struct{ Value T }

func (e *A[T]) MethodA() *A[T] { return nil }

type B[T any] struct{}

func (l *B[T]) MethodB() *A[T] { return nil }

type impl struct {
	MyInterface
	bPointer *B[int]
}

func New() any {
	return &impl{
		bPointer: new(B[int]),
	}
}

func main() {}
main_test.go
package main_test

import (
	"testing"

	myprog "example.com/myprog"
)

type E struct{ any }

func New2() *E {
	return &E{any: myprog.New()}
}

func TestNop(t *testing.T) {}

I try to test, then test with the race detector...

> go test .
ok      example.com/myprog      0.349s

> go test . -race
# example.com/myprog_test [example.com/myprog.test]
<autogenerated>:1: internal compiler error: Dictionary should have already been generated: example.com/myprog..dict.(*A[int]).MethodA

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
FAIL    example.com/myprog [build failed]
FAIL

>

What did you expect to see?

ok      example.com/myprog      0.349s

What did you see instead?

# example.com/myprog_test [example.com/myprog.test]
<autogenerated>:1: internal compiler error: Dictionary should have already been generated: example.com/myprog..dict.(*A[int]).MethodA

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
FAIL    example.com/myprog [build failed]
FAIL

Workarounds

  • Moving MyInterface below bPointer *B[int] in struct impl resolves the issue.
  • Removing MethodA or MethodB from their respective structs resolves the issue.
  • Removing New2 from the test file resolves the issue.
  • Making struct A or B non-generic resolves the issue.
  • Running go clean -cache, go clean -modcache, and restarting my terminal has also resolved the issue.
@ianlancetaylor ianlancetaylor changed the title cmd/go: testing with -race emits internal compiler error cmd/compile: testing with -race emits internal compiler error Jun 23, 2022
@ianlancetaylor
Copy link
Contributor

CC @randall77 @mdempsky

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 23, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.20 milestone Jun 23, 2022
@ZekeLu
Copy link
Contributor

ZekeLu commented Jun 24, 2022

Duplicate of #52279. And it has been fixed in go1.18.3.

@ianlancetaylor
Copy link
Contributor

Thanks.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2022
@golang golang locked and limited conversation to collaborators Jun 24, 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