Skip to content

cmd/compile: internal compiler error: panic with range over integer value #67141

Closed
@mmp

Description

@mmp

Go version

go version go1.22.2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mmp/Library/Caches/go-build'
GOENV='/Users/mmp/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mmp/go/pkg/mod'
GONOPROXY='github.com/mmp/vatce'
GONOSUMDB='github.com/mmp/vatce'
GOOS='darwin'
GOPATH='/Users/mmp/go'
GOPRIVATE='github.com/mmp/vatce'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/mmp/bork/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/d9/9chq958s5sq76cb02ws8cgkr0000gp/T/go-build2438242053=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

% go build .

Repo: bork.zip

I have determined that changing line 412 of fonts.go from:

for j := range glyph.Bounds[0]

to

for j := 0; j < glyph.Bounds[0]; j++ {

makes the compiler stop crashing.

What did you see happen?

% go build .
# github.com/mmp/imgui-go/v4
warning: unknown warning option '-Wno-subobject-linkage' [-Wunknown-warning-option]
# github.com/mmp/vice
<unknown line number>: 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
%

What did you expect to see?

Successful compilation of my program.

Activity

changed the title [-]pkg/tool/compile: internal compiler error: panic with range over integer value[/-] [+]cmd/compile: internal compiler error: panic with range over integer value[/+] on May 2, 2024
seankhliao

seankhliao commented on May 2, 2024

@seankhliao
Member

stacktrace:

<unknown line number>: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference

goroutine 1 [running]:
runtime/debug.Stack()
	../../../sdk/gotip/src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0x6c22e40?, 0xc0?}, {0xe021ac, 0x9}, {0xc006c22e70, 0x1, 0x1})
	../../../sdk/gotip/src/cmd/compile/internal/base/print.go:225 +0x1d7
cmd/compile/internal/base.Fatalf(...)
	../../../sdk/gotip/src/cmd/compile/internal/base/print.go:194
cmd/compile/internal/gc.handlePanic()
	../../../sdk/gotip/src/cmd/compile/internal/gc/main.go:52 +0x90
panic({0xd7dd20?, 0x148b970?})
	../../../sdk/gotip/src/runtime/panic.go:759 +0x132
cmd/compile/internal/types2.(*Checker).handleBailout(0xc000102380, 0xc006c27150)
	../../../sdk/gotip/src/cmd/compile/internal/types2/check.go:373 +0x88
panic({0xd7dd20?, 0x148b970?})
	../../../sdk/gotip/src/runtime/panic.go:759 +0x132
cmd/compile/internal/noder.checkFiles.func1({0xf67240?, 0xc004c8d300?})
	../../../sdk/gotip/src/cmd/compile/internal/noder/irgen.go:80 +0x209
cmd/compile/internal/types2.(*Checker).handleError(0xc000102380, 0x0, {0xc0004d7410?, 0x62a101?, 0xc0?}, 0x6d, {0xc000d9e6c0, 0x52}, 0x1)
	../../../sdk/gotip/src/cmd/compile/internal/types2/errors.go:206 +0x3de
cmd/compile/internal/types2.(*error_).report(0xc006c23378)
	../../../sdk/gotip/src/cmd/compile/internal/types2/errors.go:147 +0x21b
cmd/compile/internal/types2.(*Checker).softErrorf(0xe1454e?, {0xf67500?, 0xc004c8d200?}, 0xf6bf10?, {0xe14536?, 0x14aaa80?}, {0xc006c23558?, 0x147dec0?, 0xf68088?})
	../../../sdk/gotip/src/cmd/compile/internal/types2/errors.go:235 +0x7c
cmd/compile/internal/types2.(*Checker).rangeStmt(0xc000102380, 0x3, 0xc000629450, 0xf68088?)
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:865 +0x4dd
cmd/compile/internal/types2.(*Checker).stmt(0xc000102380, 0x3, {0xf6a170, 0xc000629450})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:642 +0x534
cmd/compile/internal/types2.(*Checker).stmtList(0xc000102380, 0x3, {0xc0001a1c20?, 0xdfb9e8?, 0x5?})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:120 +0x85
cmd/compile/internal/types2.(*Checker).stmt(0xc000102380, 0x3, {0xf69f78, 0xc000621040})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:554 +0x7c5
cmd/compile/internal/types2.(*Checker).rangeStmt(0xc000102380, 0x3, 0xc000629220, 0xc000620f40?)
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:975 +0x72d
cmd/compile/internal/types2.(*Checker).stmt(0xc000102380, 0x3, {0xf6a170, 0xc000629220})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:642 +0x534
cmd/compile/internal/types2.(*Checker).stmtList(0xc000102380, 0x3, {0xc000621240?, 0xdfb9e8?, 0x5?})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:120 +0x85
cmd/compile/internal/types2.(*Checker).stmt(0xc000102380, 0x3, {0xf69f78, 0xc000620f00})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:554 +0x7c5
cmd/compile/internal/types2.(*Checker).rangeStmt(0xc000102380, 0x3, 0xc000628be0, 0xf700c0?)
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:975 +0x72d
cmd/compile/internal/types2.(*Checker).stmt(0xc000102380, 0x3, {0xf6a170, 0xc000628be0})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:642 +0x534
cmd/compile/internal/types2.(*Checker).stmtList(0xc000102380, 0x3, {0xc0006212c0?, 0xdfb9e8?, 0x5?})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:120 +0x85
cmd/compile/internal/types2.(*Checker).stmt(0xc000102380, 0x3, {0xf69f78, 0xc000620e40})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:554 +0x7c5
cmd/compile/internal/types2.(*Checker).rangeStmt(0xc000102380, 0x3, 0xc000628910, 0xf700c0?)
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:975 +0x72d
cmd/compile/internal/types2.(*Checker).stmt(0xc000102380, 0x0, {0xf6a170, 0xc000628910})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:642 +0x534
cmd/compile/internal/types2.(*Checker).stmtList(...)
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:120
cmd/compile/internal/types2.(*Checker).funcBody(0xc000102380, 0xc00060d9e0?, {0xc0001dac48?, 0xc0004d6c60?}, 0xc0067ccc40, 0xc000620d00, {0x0?, 0x0?})
	../../../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:40 +0x34c
cmd/compile/internal/types2.(*Checker).funcDecl.func1()
	../../../sdk/gotip/src/cmd/compile/internal/types2/decl.go:784 +0x3a
cmd/compile/internal/types2.(*Checker).processDelayed(0xc000102380, 0x0)
	../../../sdk/gotip/src/cmd/compile/internal/types2/check.go:471 +0x19c
cmd/compile/internal/types2.(*Checker).checkFiles(0xc000102380, {0xc00353a000, 0x1d, 0x1d})
	../../../sdk/gotip/src/cmd/compile/internal/types2/check.go:417 +0xd6
cmd/compile/internal/types2.(*Checker).Files(0x7ffc4b68327a?, {0xc00353a000?, 0x0?, 0x0?})
	../../../sdk/gotip/src/cmd/compile/internal/types2/check.go:391 +0x85
cmd/compile/internal/types2.(*Config).Check(0xc0001300e0, {0x7ffc4b68327a?, 0xc000012137?}, {0xc00353a000, 0x1d, 0x1d}, 0xc003534840)
	../../../sdk/gotip/src/cmd/compile/internal/types2/api.go:476 +0x66
cmd/compile/internal/noder.checkFiles({0x0, {0x0, 0x0}}, {0xc0004d4000, 0x1d, 0x0?})
	../../../sdk/gotip/src/cmd/compile/internal/noder/irgen.go:91 +0x5c9
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0xc0004d4000, 0x1d, 0x1d})
	../../../sdk/gotip/src/cmd/compile/internal/noder/unified.go:304 +0x6a
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0xc0004d4000?, 0xd45cc0?, 0x0?})
	../../../sdk/gotip/src/cmd/compile/internal/noder/unified.go:180 +0x9a
cmd/compile/internal/noder.LoadPackage({0xc0001ba0f8, 0x1d, 0x20})
	../../../sdk/gotip/src/cmd/compile/internal/noder/noder.go:77 +0x43a
cmd/compile/internal/gc.Main(0xe3bec0)
	../../../sdk/gotip/src/cmd/compile/internal/gc/main.go:197 +0xbbd
main.main()
	../../../sdk/gotip/src/cmd/compile/main.go:57 +0xf9
added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on May 2, 2024
added this to the Go1.23 milestone on May 15, 2024
griesemer

griesemer commented on May 16, 2024

@griesemer
Contributor

I cannot reproduce this, neither at go1.22.3 nor at tip (haven't tried go1.22.2). In both cases, the build terminates.
The offending for statement (playground) also works fine stand-alone.
Can you please try this again with the latest version of go1.22, or if you don't mind, at tip?

I'm going to close this for now as not reproducible, but feel free to reopen if you still see the problem with up-to-date compilers. If you see the problem, it would be helpful if you could reduced the source to a (ideally small) snippet of code.

mmp

mmp commented on May 16, 2024

@mmp
Author

I'm still seeing it here with 1.22.3 as well as with gotip at

HEAD is now at 78e50d0 crypto/tls: don't call tlsrsakex.IncNonDefault with FIPS

And yes, I couldn't come up with a small repo case in the playground, so unfortunately it's this big blob of code.

The stacktrace I get with gotip is similar to the one that @seankhliao posted; the one I got is copied below. Let me know if I can help with further digging here...

% gotip build .
# github.com/mmp/imgui-go/v4
warning: unknown warning option '-Wno-subobject-linkage' [-Wunknown-warning-option]
# github.com/mmp/vice
<unknown line number>: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference

goroutine 1 [running]:
runtime/debug.Stack()
	../sdk/gotip/src/runtime/debug/stack.go:26 +0x64
cmd/compile/internal/base.FatalfAt({0x3a2ed88?, 0x140?}, {0x103051deb, 0x9}, {0x14003a2edb8, 0x1, 0x1})
	../sdk/gotip/src/cmd/compile/internal/base/print.go:230 +0x20c
cmd/compile/internal/base.Fatalf(...)
	../sdk/gotip/src/cmd/compile/internal/base/print.go:195
cmd/compile/internal/gc.handlePanic()
	../sdk/gotip/src/cmd/compile/internal/gc/main.go:53 +0x8c
panic({0x10329b500?, 0x1039710d0?})
	../sdk/gotip/src/runtime/panic.go:759 +0x124
cmd/compile/internal/types2.(*Checker).handleBailout(0x14000482380, 0x14003a33158)
	../sdk/gotip/src/cmd/compile/internal/types2/check.go:390 +0x9c
panic({0x10329b500?, 0x1039710d0?})
	../sdk/gotip/src/runtime/panic.go:759 +0x124
cmd/compile/internal/noder.checkFiles.func1({0x103350600?, 0x1400512a4c0?})
	../sdk/gotip/src/cmd/compile/internal/noder/irgen.go:78 +0x1b0
cmd/compile/internal/types2.(*Checker).handleError(0x14000482380, 0x0, {0x14000a7aa80?, 0xd27200?, 0x140?}, 0x6d, {0x14000138f60, 0x52}, 0x1)
	../sdk/gotip/src/cmd/compile/internal/types2/errors.go:206 +0x304
cmd/compile/internal/types2.(*error_).report(0x14003a2f2e8)
	../sdk/gotip/src/cmd/compile/internal/types2/errors.go:147 +0x1f4
cmd/compile/internal/types2.(*Checker).softErrorf(0x1030664fc?, {0x103350900?, 0x1400512a3c0?}, 0x1033575d0?, {0x1030664e4?, 0x4000?}, {0x14003a2f4d8?, 0x103352548?, 0x14006ac9d60?})
	../sdk/gotip/src/cmd/compile/internal/types2/errors.go:235 +0x70
cmd/compile/internal/types2.(*Checker).rangeStmt(0x14000482380, 0x3, 0x14000d32a00, 0x0?)
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:865 +0x3dc
cmd/compile/internal/types2.(*Checker).stmt(0x14000482380, 0x3, {0x103355130, 0x14000d32a00})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:642 +0x43c
cmd/compile/internal/types2.(*Checker).stmtList(0x14000482380, 0x3, {0x14000a6d150?, 0x10304b0ee?, 0x5?})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:120 +0x88
cmd/compile/internal/types2.(*Checker).stmt(0x14000482380, 0x3, {0x103354f38, 0x14000d29080})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:554 +0x628
cmd/compile/internal/types2.(*Checker).rangeStmt(0x14000482380, 0x3, 0x14000d327d0, 0x14000d28f80?)
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:988 +0x550
cmd/compile/internal/types2.(*Checker).stmt(0x14000482380, 0x3, {0x103355130, 0x14000d327d0})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:642 +0x43c
cmd/compile/internal/types2.(*Checker).stmtList(0x14000482380, 0x3, {0x14000d29280?, 0x10304b0ee?, 0x5?})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:120 +0x88
cmd/compile/internal/types2.(*Checker).stmt(0x14000482380, 0x3, {0x103354f38, 0x14000d28f40})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:554 +0x628
cmd/compile/internal/types2.(*Checker).rangeStmt(0x14000482380, 0x3, 0x14000d32190, 0x10335bde0?)
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:988 +0x550
cmd/compile/internal/types2.(*Checker).stmt(0x14000482380, 0x3, {0x103355130, 0x14000d32190})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:642 +0x43c
cmd/compile/internal/types2.(*Checker).stmtList(0x14000482380, 0x3, {0x14000d29300?, 0x10304b0ee?, 0x5?})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:120 +0x88
cmd/compile/internal/types2.(*Checker).stmt(0x14000482380, 0x3, {0x103354f38, 0x14000d28e80})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:554 +0x628
cmd/compile/internal/types2.(*Checker).rangeStmt(0x14000482380, 0x3, 0x14000d31e00, 0x10335bde0?)
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:988 +0x550
cmd/compile/internal/types2.(*Checker).stmt(0x14000482380, 0x0, {0x103355130, 0x14000d31e00})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:642 +0x43c
cmd/compile/internal/types2.(*Checker).stmtList(...)
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:120
cmd/compile/internal/types2.(*Checker).funcBody(0x14000482380, 0x14000d26b40?, {0x140006314d0?, 0x14000a7a2d0?}, 0x140014ace00, 0x14000d28d40, {0x0?, 0x0?})
	../sdk/gotip/src/cmd/compile/internal/types2/stmt.go:40 +0x268
cmd/compile/internal/types2.(*Checker).funcDecl.func1()
	../sdk/gotip/src/cmd/compile/internal/types2/decl.go:784 +0x44
cmd/compile/internal/types2.(*Checker).processDelayed(...)
	../sdk/gotip/src/cmd/compile/internal/types2/check.go:502
cmd/compile/internal/types2.(*Checker).checkFiles(0x14000482380, {0x14003352000, 0x1d, 0x1d})
	../sdk/gotip/src/cmd/compile/internal/types2/check.go:448 +0x6ec
cmd/compile/internal/types2.(*Checker).Files(0x16d782a6f?, {0x14003352000?, 0x0?, 0x0?})
	../sdk/gotip/src/cmd/compile/internal/types2/check.go:408 +0x80
cmd/compile/internal/types2.(*Config).Check(0x140004b5ea0, {0x16d782a6f?, 0x140000101c7?}, {0x14003352000, 0x1d, 0x1d}, 0x1400334acc0)
	../sdk/gotip/src/cmd/compile/internal/types2/api.go:480 +0x68
cmd/compile/internal/noder.checkFiles({0x0, {0x0, 0x0}}, {0x14000434000, 0x1d, 0x140000769a0?})
	../sdk/gotip/src/cmd/compile/internal/noder/irgen.go:89 +0x4ac
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0x14000434000, 0x1d, 0x1d})
	../sdk/gotip/src/cmd/compile/internal/noder/unified.go:307 +0x48
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0x14000434000?, 0x10324cf20?, 0x0?})
	../sdk/gotip/src/cmd/compile/internal/noder/unified.go:183 +0x98
cmd/compile/internal/noder.LoadPackage({0x14000020408, 0x1d, 0x1f})
	../sdk/gotip/src/cmd/compile/internal/noder/noder.go:77 +0x398
cmd/compile/internal/gc.Main(0x10334aa20)
	../sdk/gotip/src/cmd/compile/internal/gc/main.go:200 +0xb40
main.main()
	../sdk/gotip/src/cmd/compile/main.go:57 +0x110
mmp

mmp commented on May 16, 2024

@mmp
Author

(I'm unable to reopen the bug myself, it seems.)

19 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

FixPendingIssues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Done

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @mmp@dmitshur@griesemer@gopherbot@seankhliao

      Issue actions

        cmd/compile: internal compiler error: panic with range over integer value · Issue #67141 · golang/go