Skip to content

cmd/compile: index out of range error prints wrong length #75327

@dominikh

Description

@dominikh

Go version

go version go1.26-devel_076eae436e Thu Jul 24 16:06:16 2025 -0700 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/dominikh/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/dominikh/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build145267961=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/dominikh/prj/src/example.com/bar/go.mod'
GOMODCACHE='/home/dominikh/prj/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/dominikh/prj'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/dominikh/prj/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/dominikh/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/dominikh/prj/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26-devel_076eae436e Thu Jul 24 16:06:16 2025 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Compile and run https://go.dev/play/p/56Wgi7uvh2j?v=gotip

What did you see happen?

panic: runtime error: index out of range [1] with length 824634369848

goroutine 1 [running]:
main.foo({0xc00009e738?, 0xc00009e740?, 0x474f00?})
	/home/dominikh/prj/src/example.com/bar/bar.go:10 +0x45
main.main()
	/home/dominikh/prj/src/example.com/bar/bar.go:4 +0x29
exit status 2

What did you expect to see?

I expected the correct length of the slice to be printed.

git bisect points to 076eae4; it still reproduces on master.

commit 076eae436e63f33cc5999f8e2e1822f3396af3b1 (HEAD)
Author: Keith Randall <khr@golang.org>
Date:   Wed Jun 18 15:14:00 2025 -0700

    cmd/compile: move amd64 and 386 over to new bounds check strategy
    
    Change-Id: I13f54f04ccb8452e625dba4249e0d56bafd1fad8
    Reviewed-on: https://go-review.googlesource.com/c/go/+/682397
    Reviewed-by: Michael Knyszek <mknyszek@google.com>
    LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
    Reviewed-by: David Chase <drchase@google.com>

/cc @randall77

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions