Skip to content

cmd/compile: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference iter/iter.go:223:6 #82144

Closed as duplicate

Description

@81hvac1k02

Go version

go version go1.27.1-X:nodwarf5 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='/home/steve/go/bin'
GOCACHE='/home/steve/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/steve/.config/go/env'
GOEXE=''
GOEXPERIMENT='nodwarf5'
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3177634082=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/steve/Documents/testingStuff/goExperimental/go.mod'
GOMODCACHE='/home/steve/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPACKAGESDRIVER=''
GOPATH='/home/steve/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/steve/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.27.1-X:nodwarf5'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

When writing a benchmark i encountered a compiler panic, i have made a minimal copy of the problematic code.

package main

import (
	"regexp"
	"testing"
)

var (
	testRE  = regexp.MustCompile(`\/search`)
	testStr = "https://x.com/search?q=golang"
)

func BenchmarkRe(b *testing.B) {
	for b.Loop() {
		switch {
		case testRE.MatchString(testStr):
			
		}

	}
}

When trying to figure out what triggered this failure i discovered that changing the case to negative didn't cause a panic at all.

So this version runs the benchmark as expected:

package main

import (
	"regexp"
	"testing"
)

var (
	testRE  = regexp.MustCompile(`\/search`)
	testStr = "https://x.com/search?q=golang"
)

func BenchmarkRe(b *testing.B) {
	for b.Loop() {
		switch {
		case !testRE.MatchString(testStr):

		}

	}
}

What did you see happen?

go test -bench .
"# goExperiment [goExperiment.test]
/usr/lib/go/src/iter/iter.go:223:6: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference

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

What did you expect to see?

I expected the benchmark to run as normal

Activity

  1. changed the title [-]test: "internal compiler error: panic" when running go test[/-] [+]cmd/compile: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference iter/iter.go:223:6[/+] on Oct 11, 2026
  2. thepudds commented on Oct 11, 2026

    @thepudds
    Member

    This seems fixed on master as of 412d6e1:

      GOOD master: 2c3c1caad2 | 2026-10-10 23:21 | cmd/compile: record method indices before encoding a named type
      first FIX:   412d6e161f | 2026-08-11 14:11 | cmd/compile: avoid rewriting switch case expressions in b.Loop
      BAD parent:  a2674e7ab8 | 2026-08-11 14:11 | all: point stale keep-in-sync comments at the files that exist
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions