Skip to content

cmd/compile: internal compiler error: next missing from LHS of .autotmp_23, _ := ([]byte)(.autotmp_4), 0 #73823

Closed
@Rajalakshmi-Girish

Description

@Rajalakshmi-Girish

Go version

go version go1.25-devel_a8e0641d5b

Output of go env in your module/workspace:

[root@raji-x86-workspace1 kubernetes]# go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='0'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4279966289=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/root/kubernetes/go.mod'
GOMODCACHE=''
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH=''
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25-devel_53b9eae387 Wed May 21 21:20:52 2025 -0700'
GOWORK='/root/kubernetes/go.work'
PKG_CONFIG='pkg-config'
[root@raji-x86-workspace1 kubernetes]#

What did you do?

git clone https://github.com/kubernetes/kubernetes
export CGO_ENABLED=0
export FORCE_HOST_GO=y
KUBE_BUILD_PLATFORMS=linux/x86_64 make cross

What did you see happen?

[root@raji-x86-workspace1 kubernetes]# KUBE_BUILD_PLATFORMS=linux/x86_64 make cross
+++ [0521 23:22:26] Building go targets for linux/amd64
    k8s.io/apiextensions-apiserver (static)
    k8s.io/component-base/logs/kube-log-runner (static)
    k8s.io/kube-aggregator (static)
    k8s.io/kubernetes/cluster/gce/gci/mounter (static)
    k8s.io/kubernetes/cmd/kubeadm (static)
    k8s.io/kubernetes/cmd/kube-apiserver (static)
    k8s.io/kubernetes/cmd/kube-controller-manager (static)
    k8s.io/kubernetes/cmd/kubelet (non-static)
    k8s.io/kubernetes/cmd/kube-proxy (static)
    k8s.io/kubernetes/cmd/kube-scheduler (static)
+++ [0521 23:23:10] Building go targets for linux/amd64
    k8s.io/component-base/logs/kube-log-runner (static)
    k8s.io/kubernetes/cmd/kubeadm (static)
    k8s.io/kubernetes/cmd/kubelet (non-static)
    k8s.io/kubernetes/cmd/kube-proxy (static)
+++ [0521 23:23:37] Building go targets for linux/amd64
    k8s.io/kubernetes/cmd/kubectl (static)
    k8s.io/kubernetes/cmd/kubectl-convert (static)
+++ [0521 23:24:12] Building go targets for linux/amd64
    github.com/onsi/ginkgo/v2/ginkgo (non-static)
    k8s.io/kubernetes/test/conformance/image/go-runner (non-static)
    k8s.io/kubernetes/test/e2e/e2e.test (test)
+++ [0521 23:25:34] Building go targets for linux/amd64
    github.com/onsi/ginkgo/v2/ginkgo (non-static)
    k8s.io/kubernetes/cmd/kubemark (static)
    k8s.io/kubernetes/test/e2e_node/e2e_node.test (test)
# go.etcd.io/etcd/server/v3/storage/backend
sync/atomic/type.go:47:6: internal compiler error: next missing from LHS of .autotmp_23, _ := ([]byte)(.autotmp_4), 0

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
!!! [0521 23:26:00] Call tree:
!!! [0521 23:26:00]  1: /root/kubernetes/hack/lib/golang.sh:997 kube::golang::build_binaries_for_platform(...)
!!! [0521 23:26:00]  2: hack/make-rules/build.sh:28 kube::golang::build_binaries(...)
!!! [0521 23:26:00] Call tree:
!!! [0521 23:26:00]  1: hack/make-rules/build.sh:28 kube::golang::build_binaries(...)
make[1]: *** [Makefile:97: all] Error 1
make: *** [Makefile:496: cross] Error 1
[root@raji-x86-workspace1 kubernetes]#

What did you expect to see?

Build of Kubernetes successful.

Activity

mkumatag

mkumatag commented on May 22, 2025

@mkumatag

simple repro steps:

$ git clone https://github.com/kubernetes/kubernetes.git
$ cd kubernetes
$ go test -c k8s.io/kubernetes/test/e2e_node
# go.etcd.io/etcd/server/v3/storage/backend
/usr/local/go/src/sync/atomic/type.go:47:6: internal compiler error: next missing from LHS of .autotmp_23, _ := ([]byte)(.autotmp_4), 0

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

mateusz834 commented on May 22, 2025

@mateusz834
Member

This assertion is hit in ReassignOracle:

base.Fatalf("%v missing from LHS of %v", n, defn)

# go.etcd.io/etcd/server/v3/storage/backend
goroutine 1 [running]:
cmd/compile/internal/ir.(*ReassignOracle).staticValue1(0xc0020789c0, {0x10639d0, 0xc00185c3c0})
        /home/mateusz/code/go/src/cmd/compile/internal/ir/reassignment.go:184 +0x27e
cmd/compile/internal/ir.(*ReassignOracle).StaticValue(0xc0020789c0, {0x10639d0?, 0xc00185c3c0?})
        /home/mateusz/code/go/src/cmd/compile/internal/ir/reassignment.go:144 +0xb2
cmd/compile/internal/escape.(*batch).rewriteWithLiterals(0xc002097d48, {0x1064268, 0xc0017e3d80}, 0xc001859680)
        /home/mateusz/code/go/src/cmd/compile/internal/escape/escape.go:573 +0x1cb
cmd/compile/internal/escape.Batch({0xc00207ea00, 0x4, 0x10}, 0x0?)
        /home/mateusz/code/go/src/cmd/compile/internal/escape/escape.go:162 +0x2d7
cmd/compile/internal/ir.(*bottomUpVisitor).visit(...)
        /home/mateusz/code/go/src/cmd/compile/internal/ir/scc.go:121
cmd/compile/internal/ir.VisitFuncsBottomUp({0xc001bbcc08, 0x198, 0x2?}, 0xf13678)
        /home/mateusz/code/go/src/cmd/compile/internal/ir/scc.go:58 +0x3c2
cmd/compile/internal/escape.Funcs(...)
        /home/mateusz/code/go/src/cmd/compile/internal/escape/escape.go:125
cmd/compile/internal/gc.Main(0xf134b8)
        /home/mateusz/code/go/src/cmd/compile/internal/gc/main.go:269 +0x1f0d
main.main()
        /home/mateusz/code/go/src/cmd/compile/main.go:57 +0xf9

It looks like CL 649079/CL 673795

CC @golang/compiler @thepudds

added this to the Go1.25 milestone on May 22, 2025
Rajalakshmi-Girish

Rajalakshmi-Girish commented on May 22, 2025

@Rajalakshmi-Girish
Author
mateusz834

mateusz834 commented on May 22, 2025

@mateusz834
Member

After a quick debugging session:

I believe this is unrelated to these change - in a sense that these changes exposed a bug elsewhere.
For me it looks like it is related to loopvar logic in the compiler (loopvar.ForCapture).

diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go
index 253ec3257a..f6bf13a03b 100644
--- a/src/cmd/compile/internal/gc/main.go
+++ b/src/cmd/compile/internal/gc/main.go
@@ -240,22 +240,53 @@ func Main(archInit func(*ssagen.ArchInfo)) {
        interleaved.DevirtualizeAndInlinePackage(typecheck.Target, profile)

        noder.MakeWrappers(typecheck.Target) // must happen after inlining

        // Get variable capture right in for loops.
        var transformed []loopvar.VarAndLoop
        for _, fn := range typecheck.Target.Funcs {
                transformed = append(transformed, loopvar.ForCapture(fn)...)
        }
        ir.CurFunc = nil

+       for _, f := range typecheck.Target.Funcs {
+               ir.Visit(f, func(nn ir.Node) {
+                       if nn.Op() != ir.ONAME {
+                               return
+                       }
+                       n := nn.(*ir.Name).Canonical()
+                       if n.Class != ir.PAUTO {
+                               return
+                       }
+
+                       defn := n.Defn
+                       if defn == nil {
+                               return
+                       }
+
+               FindRHS:
+                       switch defn.Op() {
+                       case ir.OAS2:
+                               defn := defn.(*ir.AssignListStmt)
+                               for _, lhs := range defn.Lhs {
+                                       if lhs == n {
+                                               break FindRHS
+                                       }
+                               }
+                               base.FatalfAt(n.Pos(), "%v HERE missing from LHS of %v\n%v", n, defn)
+                       default:
+                               return
+                       }
+               })
+       }
+
        // Build init task, if needed.
        pkginit.MakeTask()

If you apply this change before the ForCapture calls, then the FatalfAt call is not reached, when i move if after the ForCapture calls (exactly as the diff above) it fails.

thepudds

thepudds commented on May 22, 2025

@thepudds
Member

Hi @mateusz834, thanks for taking a quick look! (I'm just coming online; I'll start digging in shortly).

gopherbot

gopherbot commented on May 22, 2025

@gopherbot
Contributor

Change https://go.dev/cl/675475 mentions this issue: cmd/compile: fix ICE when transforming loopvar

cuonglm

cuonglm commented on May 22, 2025

@cuonglm
Member

Hi @mateusz834, thanks for taking a quick look! (I'm just coming online; I'll start digging in shortly).

I think the problem is that loopvar transforming the for variable without updating its Defn properly, causing incorrect asignment statement check of ReassignOracle.

thepudds

thepudds commented on May 22, 2025

@thepudds
Member

This set of repro steps seem to work now with https://go.dev/cl/675475 from @cuonglm:

$ go install golang.org/dl/gotip@latest
$ gotip download 675475
$ git clone --depth=1 https://github.com/kubernetes/kubernetes.git
$ cd kubernetes/ 
$ gotip test -c k8s.io/kubernetes/test/e2e_node
thepudds

thepudds commented on May 22, 2025

@thepudds
Member

From the kubernetes directory, this also seems to work now:

$ gotip build ./... && gotip test -c ./...
cuonglm

cuonglm commented on May 22, 2025

@cuonglm
Member

This set of repro steps seem to work now with https://go.dev/cl/675475 from @cuonglm:

$ go install golang.org/dl/gotip@latest
$ gotip download 675475
$ git clone --depth=1 https://github.com/kubernetes/kubernetes.git
$ cd kubernetes/ 
$ gotip test -c k8s.io/kubernetes/test/e2e_node

Yeah, I am still working on a standalone reproducer.

cuonglm

cuonglm commented on May 22, 2025

@cuonglm
Member

Standalone reproducer:


package p

type Backend interface {
	Hash(ignores func(bucketName, keyName []byte) bool) (uint32, error)
}

type backend struct {
}

func first() (key []byte, value []byte) {
	return
}

func (b *backend) View(fn func() error) error {
	return nil
}

func (b *backend) Hash(ignores func(bucketName, keyName []byte) bool) (uint32, error) {
	err := b.View(func() error {
		for next, _ := first(); next != nil; next, _ = first() {
			_ = next
		}
		return nil
	})
	return 0, err
}

func defragdb() error {
	for next, _ := first(); next != nil; next, _ = first() {
		_ = f(next)
		ForEach(func(k, v []byte) error {
			_ = next
			return nil
		})
	}

	return nil
}

func ForEach(fn func(k, v []byte) error) error {
	for k, v := first(); k != nil; k, v = first() {
		if err := fn(k, v); err != nil {
			return err
		}
	}
	return nil
}

//go:noinline
func f(any) string {
	return ""
}
gopherbot

gopherbot commented on May 22, 2025

@gopherbot
Contributor

Change https://go.dev/cl/675495 mentions this issue: cmd/compile: use better fatal message for staticValue1

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @cuonglm@gopherbot@mkumatag@mateusz834@thepudds

      Issue actions

        cmd/compile: internal compiler error: next missing from LHS of .autotmp_23, _ := ([]byte)(.autotmp_4), 0 · Issue #73823 · golang/go