go: cmd/compile: typebits.Set: invalid initial alignment: type Peer has alignment 8, but offset is 4

This is seems to be a regression of: https://github.com/golang/go/issues/54638

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

go version go1.19.1 linux/arm64

Does this issue reproduce with the latest release?

Not, tested.

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

go env Output
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/stv0g/.cache/go-build"
GOENV="/home/stv0g/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/stv0g/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/stv0g/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/stv0g/workspace/cunicu2/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 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3584615060=/tmp/go-build -gno-record-gcc-switches"

What did you do?

git clone github.com/stv0g/cunicu
cd cunicu
GOARCH=arm go build ./cmd/cunicu

What did you expect to see?

A successful build for 32-bit architectures.

What did you see instead?

The following compiler error:

# github.com/stv0g/cunicu/pkg/feat/epdisc
<autogenerated>:1: internal compiler error: typebits.Set: invalid initial alignment: type Peer has alignment 8, but offset is 4

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

This issue has been observed for the following GOARCH=arm, mips and GOOS=linux 64-bit builds (GOOS=arm64, amd64) are successful.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (14 by maintainers)

Most upvoted comments

@randall77 @cherrymui should we backport this?

@stv0g one way to workaround is not using the embedded interface type, making it an explicit field instead. For example, for the reproducer above, you can do:

package p

import "sync/atomic"

type I interface {
	M()
}

type S struct{}

func (S) M() {}

type T struct {
	i I
	x atomic.Int64
}

func F() {
	t := T{i: S{}}
	t.i.M()
}

Notice I is changed from embedded field to i I. That way, the compiler won’t have to generate the wrapper.