Repository navigation
Closed
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
The following code:
package main
import (
"reflect"
)
func intPtrTypeKind() reflect.Kind {
return reflect.TypeFor[*int]().Kind()
}
type large struct {
large_d430158
b [1500000000]byte
}
type large_d430158 struct {
b [1500000000]byte
}Resulted in this output:
# fflreduce
./main.go:12:6: internal compiler error: bad type: struct { large_d430158; b [1500000000]byte }
goroutine 1 [running]:
runtime/debug.Stack()
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0x1ccfdc0?, 0x0?}, {0x103add2, 0xc}, {0x3bc9129eeaa8, 0x1, 0x1})
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/base/print.go:232 +0x18b
cmd/compile/internal/base.Fatalf(...)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/base/print.go:197
cmd/compile/internal/types.typePos(0x59682f00?)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/types/size.go:54 +0x90
cmd/compile/internal/types.calcStructOffset(0x3bc912a0e9c0, {0x3bc91250fcb0, 0x2, 0x1?}, 0x1?)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/types/size.go:193 +0x111
cmd/compile/internal/types.CalcStructSize(...)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/types/size.go:522
cmd/compile/internal/types.CalcSize(0x3bc912a0e9c0)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/types/size.go:420 +0xa25
cmd/compile/internal/types.ResumeCheckSize()
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/types/size.go:721 +0x65
cmd/compile/internal/noder.(*pkgReader).objIdxMayFail(0x3bc9129bc1c0, 0x5, {0x0, 0x0, 0x0}, {0x1d10160, 0x0, 0x0}, 0x0)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/reader.go:855 +0x82a
cmd/compile/internal/noder.(*pkgReader).objIdx(...)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/reader.go:684
cmd/compile/internal/noder.(*pkgReader).objInstIdx(0x3bc9129bc1c0, {0x6?, {0x3bc9129ef258?, 0x3bc9129bc1c0?, 0x3bc912504ae0?}}, 0x0, 0x0)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/reader.go:676 +0x8f
cmd/compile/internal/noder.(*reader).obj(0x3bc9125194a0)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/reader.go:646 +0x13c
cmd/compile/internal/noder.(*reader).pkgObjs(0x3bc9125194a0, 0x3bc9126b4240)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/reader.go:3684 +0x9b
cmd/compile/internal/noder.(*reader).pkgDecls(0x3bc9125194a0, 0x3bc9126b4240)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/reader.go:3673 +0x194
cmd/compile/internal/noder.(*reader).pkgInit(0x3bc9125194a0, 0x3bc9126bb8b0?, 0x3bc9126b4240)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/reader.go:3537 +0xee
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0x3bc9124dc6e8?, 0x197aba0?, 0x1b53b98?})
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/unified.go:206 +0x1f9
cmd/compile/internal/noder.LoadPackage({0x3bc9124fc270, 0x1, 0x1})
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/noder/noder.go:76 +0x525
cmd/compile/internal/gc.Main(0x1a77de0)
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/gc/main.go:219 +0xd05
main.main()
/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/main.go:57 +0x105
To reproduce:
GOOS=linux GOARCH=386 go build .
Compiler version:
go version go1.28-devel_603439a1 Fri Aug 28 21:44:26 2026 -0700 linux/amd64
Commit:
603439a1c6f2d37c7f02e246342847056ed04c21
Build configuration:
cd src && ./make.bash (GOROOT_BOOTSTRAP=go1.26.0)
Operating System:
Ubuntu 22.04 Host, Docker fusion-fuzz-go:latest
This bug was found by fusion-fuzz
Metadata
Metadata
Assignees
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
- StatusShow more project fieldsDone
Activity
gabyhelp commentedon Aug 31, 2026
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
thepudds commentedon Aug 31, 2026
The
reflect.TypeFordoes not seem to be required.Also, FWIW, this does not seem to be a recently introduced problem. Not sure yet how far back it goes, but stepped back as far as 2022-08-27 and still able to reproduce it (though that required deleting the
reflect.TypeForbecause that API was not yet introduced at that time.).An actual bisect kicking off shortly...
dr2chase commentedon Aug 31, 2026
@golang/compiler
cuonglm commentedon Aug 31, 2026
I believe this was broken between go1.17 and go1.18
thepudds commentedon Aug 31, 2026
This bisected to when
Unified IRtype parameters and types2 were enabled in c991278:(That's with the
reflect.TypeForremoved).I could go further back to see what commit in the type parameters work it happened (probably), but for now, I'll leave it as "not a recent problem" as the main conclusion.
edit: sorry, I mis-remembered what -G=3 was for. It was for enabling the types2 type checker and support for type parameters, not the Unified IR work.
griesemer commentedon Aug 31, 2026
Simpler reproducer:
and then compile with
A cursory investigation shows that the compiler correctly wants to report that the struct size is too large (for x386) via cmd/compile/internal/types/size.go:193 but that (for some reason) the position of
tis unknown, which leads to the fatal error on line 54 in the same file rather than a proper error message.The position of
tis unknown becauset.objisnil. In fact,t.objis nil (almost?) always when accessed inType.Pos(cmd/compile/internal/types/type.go:279).[-]ICE: bad type: struct[/-][+]cmd/compile: internal compiler error: bad type: struct[/+]thepudds commentedon Aug 31, 2026
Hi Robert, I can't promise this is useful info, but restarting the bisect with
-G=3seemed to land on 2427f6e:(That's with
GOARCH=386 go build -gcflags=all=-G=3run onlinux/amd64.)gopherbot commentedon Aug 31, 2026
Change https://go.dev/cl/825164 mentions this issue:
cmd/compile: use field position for "struct too large" errorcmd/compile: use field position for "struct too large" error
griesemer commentedon Aug 31, 2026
The CL above fixed the internal compiler error. Also, filed #81257 to follow up. Closing.
griesemer commentedon Aug 31, 2026
@thepudds Thanks for the bisect! This looks useful for #81257 as it seems that there's something larger amiss or not well understood anymore.