You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This program produces a giant struct with n fields, and n accessor methods to get at those fields and is similar to whats generated by large protobuf files.
Compiling the program produced by this generator crashes the compiler:
$ go run gen.go > main.go
$ go run main.go
# command-line-arguments
main.go:45011: internal compiler error: methods are too far away on T: 120008
goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
/go/src/runtime/debug/stack.go:24 +0x79
cmd/compile/internal/gc.Fatalf(0x4fffff, 0x22, 0xc420c6b340, 0x2, 0x2)
/go/src/cmd/compile/internal/gc/subr.go:165 +0x248
cmd/compile/internal/gc.dextratype(0xc420e693b0, 0x54, 0xc420c40af0, 0x1d4c8, 0x50)
/go/src/cmd/compile/internal/gc/reflect.go:613 +0x2db
cmd/compile/internal/gc.dtypesym(0xc420c40af0, 0xc420c40af0)
/go/src/cmd/compile/internal/gc/reflect.go:1305 +0x103b
cmd/compile/internal/gc.dtypesym(0xc420c40c30, 0xc420c6ba20)
/go/src/cmd/compile/internal/gc/reflect.go:1278 +0xd37
cmd/compile/internal/gc.dumptypestructs()
/go/src/cmd/compile/internal/gc/reflect.go:1363 +0xcc
cmd/compile/internal/gc.dumpobj1(0x7fff5fbff451, 0x5b, 0x3)
/go/src/cmd/compile/internal/gc/obj.go:133 +0x553
cmd/compile/internal/gc.dumpobj()
/go/src/cmd/compile/internal/gc/obj.go:45 +0x52
cmd/compile/internal/gc.Main()
/go/src/cmd/compile/internal/gc/main.go:488 +0x1a5d
cmd/compile/internal/amd64.Main()
/go/src/cmd/compile/internal/amd64/galign.go:93 +0x2fa
main.main()
/go/src/cmd/compile/main.go:33 +0x2a3
Hmmm, this does seem to be a problem. The overhaul of the reflection data structures assumed that all types are small. That appears not to be the case.
Even when the offset CL series is complete in 1.8 the space needed for each struct field on amd64 will be 16-bytes, so several thousand fields will overflow a uint16. So it looks like the moff field of uncommonType needs to be 4-bytes. For alignment, mcount should probably be pushed up to 4-bytes.
I'll do this tomorrow when I'm back from vacation.
Using
go1.7beta1
Consider this generator code:
This program produces a giant struct with n fields, and n accessor methods to get at those fields and is similar to whats generated by large protobuf files.
Compiling the program produced by this generator crashes the compiler:
This did not fail with the
Go1.6
compiler./cc @crawshaw @griesemer @ianlancetaylor @randall77
The text was updated successfully, but these errors were encountered: